FacebookgraphicsApi风扇页面照片上传(IOS)

我有一个应用程序,即时上传照片,并试图添加上载到用户的Facebook粉丝页面(他们pipe理)的能力。

我遇到的问题是,我可以成功地将照片上传到粉丝页面,但粉丝页面时间轴上没有显示,只是在粉丝页面的“最近的post”部分显示。

我显然不能正确地上传这些图片。 这是我的代码:

ACAccountType * accountType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; [_accountStore requestAccessToAccountsWithType:accountType options:@{ACFacebookAppIdKey: @"XXXXXXXXXXXX", ACFacebookPermissionsKey : @[@"photo_upload",@"publish_stream", @"publish_actions", @"manage_pages"], ACFacebookAudienceKey : ACFacebookAudienceEveryone} completion:^(BOOL granted, NSError *error) { if (granted) { NSArray * accounts = [_accountStore accountsWithAccountType:accountType]; NSDictionary *fanPages = [[NSUserDefaults standardUserDefaults] objectForKey:FACEBOOK_PREF_FAN_PAGES_IDS]; //if using fan pages if (fanPages.count) { for (id key in fanPages) { //id is the key and the access token is the value NSLog(@"access token:%@, fanpage id: %@", fanPages[key], key); NSMutableString *requestURL = [NSMutableString stringWithFormat:@"https://graph.facebook.com/%@/photos/", key]; NSURL * url = [NSURL URLWithString:requestURL]; NSDictionary *parameters = @{@"access_token": [fanPages[key] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], @"no_story":@"0", @"message": hashtags}; SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:url parameters:parameters]; [request addMultipartData:UIImageJPEGRepresentation(image, 0.9) withName:@"source" type:@"application/octet-stream" filename:@"media.png"]; //NSLog(@"%@",[accounts lastObject]); [request setAccount:[accounts lastObject]]; //make request [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { NSLog(@"uploaded for %@",fanPages[key]); NSString *respData = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"responseData %@",respData); NSLog(@"urlResponse for %@",urlResponse); [self performSelectorOnMainThread:@selector(removeProgressView) withObject:nil waitUntilDone:NO]; }]; } } else { //upload to personal timeline NSURL * url = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"]; SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:url parameters:nil]; [request addMultipartData:[hashtags dataUsingEncoding:NSUTF8StringEncoding] withName:@"message" type:@"multipart/form-data" filename:nil]; [request addMultipartData:UIImageJPEGRepresentation(image, 0.9) withName:@"source" type:@"application/octet-stream" filename:@"media.png"]; [request setAccount:[accounts lastObject]]; [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { [self performSelectorOnMainThread:@selector(removeProgressView) withObject:nil waitUntilDone:NO]; }]; } } else { //theres an error or they are not granted } 

任何想法,我做错了什么? 我已经在网上search了几天,一切看起来都是正确的。

所以事实certificate,我正在做的一切正确,问题是,如果我留在:

 [request setAccount:[accounts lastObject]]; 

这会导致它以我的名义发布,并不会显示在时间轴上。 删除这段代码纠正了这个问题,我所有的post现在都出现在粉丝页面的时间轴上,而不是来自粉丝页面的用户账户。

感谢Tobi,我知道这是访问令牌,我想我是正确传递的,显然我不是。

因此,为了重新迭代,在发布到粉丝页面时不要使用setAccount,因为它将用您的用户标记而不是粉丝页面标记覆盖access_token。