gpt4 book ai didi

iphone - 必须使用事件访问 token 来查询有关当前用户的信息

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:48:59 25 4
gpt4 key购买 nike

我正在尝试获取用户详细信息,但目前无法获取图像。这是我遇到的错误:

{
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
}

这是我的代码:

   if(!self.store)
{
ACAccountStore *store1 = [[ACAccountStore alloc] init];
self.store=store1;
[store1 release];

}

ACAccountType *fbAccountType =
[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray * permissions = @[@"read_stream", @"publish_stream",@"email", @"user_birthday",@"publish_actions",@"user_photos"];
NSDictionary * dict = @{ACFacebookAppIdKey : @"my_key", ACFacebookPermissionsKey : permissions, ACFacebookAudienceKey : ACFacebookAudienceOnlyMe};
// Request permission from the user to access the available Twitter accounts
[store requestAccessToAccountsWithType:fbAccountType options:dict completion:^(BOOL granted, NSError *error) {
__block NSString * statusText = nil;
if (granted) {
statusText = @"Logged in";
NSArray * accounts = [store accountsWithAccountType:fbAccountType];
store = [accounts lastObject];
account = [accounts objectAtIndex:0];
NSLog(@"account is: %@", account);
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me?fields=picture"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:requestURL
parameters:nil];
request.account = account;
[request performRequestWithHandler:^(NSData *data,
NSHTTPURLResponse *response,
NSError *error) {

if(!error){
NSDictionary *list =[NSJSONSerialization JSONObjectWithData:data
options:kNilOptions error:&error];
NSLog(@"Dictionary contains: %@", list );
}
else{
//handle error gracefully
}

}];
}

如果我使用 https://graph.facebook.com/me作为 url 那么它工作正常。但我也需要个人资料照片。怎么办?

最佳答案

“字段”是一个参数,不是 URL 本身的一部分。这有效:

SLRequest *videoLimitsRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:@"https://graph.facebook.com/me"]
parameters:@{@"fields": @"video_upload_limits"}];

仅供引用,当您将帐户附加到 SLRequest 时, token 会自动添加。

关于iphone - 必须使用事件访问 token 来查询有关当前用户的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14775800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com