2

我有一个 Facebook 页面,我是管理员。我已登录 Facebook 并获得了FBSession.actionSession. IEisOpen = YES

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"access_token",  @"fields",
                                   nil];
    FBRequest *req = [FBRequest requestWithGraphPath:myPageID parameters:params HTTPMethod:@"POST"];
    [req startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"Result: %@", result);
        });
    }];

但是我nil进去了result。我知道我必须添加manage_pages权限,但是在哪里添加呢?

注意:我使用的是 Facebook SDK 3.5.3

调试日志记录的附加信息:

2013-06-27 12:18:34.722 TestFBPostPage[13224:19a03] FBSDKLog: Request <#1113>:
  URL:  https://graph.facebook.com/MY_PAGE_ID?sdk=ios&fields=access_token&migration_bundle=fbsdk%3A20130409&format=json&access_token=ACCESS_TOKEN_REMOVED
  Method:   POST
  UserAgent:    FBiOSSDK.3.5.3
  MIME: multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
  Attachments:  
    sdk:    ios
    fields: access_token
    migration_bundle:   fbsdk:20130409
    format: json
    access_token:   ACCESS_TOKEN_REMOVED

2013-06-27 12:18:34.952 TestFBPostPage[13224:19a03] FBSDKLog: Error: HTTP status code: 403
2013-06-27 12:18:34.954 TestFBPostPage[13224:19a03] FBSDKLog: Response <#1113> <Error>:
The operation couldn’t be completed. (com.facebook.sdk error 5.)
4

1 回答 1

0

嗯,这是 SDK 4.x,但这是我让它工作的东西

 __block NSString *pageToken;
        FBSDKGraphRequest *newRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"/%@/accounts", [FBSDKAccessToken currentAccessToken].userID] parameters:nil HTTPMethod:@"GET"];
        [newRequest startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

            if (error) {
                NSLog([error localizedDescription]);
            }else{
               //here you made need to do some debugging. not sure how it works with multiple pages
                pageToken = [[[result objectForKey:@"data"] objectAtIndex:0] objectForKey:@"access_token"];


        }];

同样,不完全确定当用户是多个页面的管理员时它是如何工作的,但是对于单页面管理员来说,这就是我要做的工作

于 2015-05-20T04:04:30.363 回答