3

ユーザーの詳細を取得しようとしていますが、現在画像を取得できません。次のエラーが表示されます。

{
    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 として使用すると、正常に動作します。でも、プロフィール写真も必要です。何をすべきか?

4

3 に答える 3

4

「fields」はパラメーターであり、URL 自体の一部ではありません。これは機能します:

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

参考までに、SLRequest にアカウントをアタッチすると、トークンが自動的に追加されます。

于 2013-11-17T20:15:00.460 に答える
0

このようにaccesstokenでfqlを実行できます

https://graph.facebook.com/fql?q=uid = YourFacebookID&access_token=ACCESSTOKENのユーザーから名前を選択

これはあなたのために働くでしょう。

于 2013-02-09T06:09:48.680 に答える