Posting a photo to Facebook fan page as user. iOS Facebook SDK 3.1

孤街浪徒 提交于 2019-12-08 11:08:58

问题



I'm trying to post a photo to Facebook page from user using Facebook SDK 3.1.
When I'm using the following code to create upload image request:

FBRequest *uploadPhotoRequest = [FBRequest requestWithGraphPath:@"/${FAN_PAGE_ID}/photos/" parameters:[NSDictionary dictionaryWithObjectsAndKeys:self.imageToShare, @"source", nil] HTTPMethod:@"POST"];

Image goes directly to user's timeline, not the page's one.

But when I'm posting a link:

FBRequest *request = [FBRequest requestWithGraphPath:@"/${FAN_PAGE_ID}/feed/" parameters:[NSDictionary dictionaryWithObjectsAndKeys:@"http://stackoverflow.com", @"link", nil] HTTPMethod:@"POST"];

Link posts correctly to the facebook page.

To open a session I'm using code:

[FBSession openActiveSessionWithPermissions:[NSArray arrayWithObjects:@"publish_stream", @"photo_upload", nil]
                               allowLoginUI:YES
                          completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
...
                          }];

I know that openActiveSessionWithPermissions is deprecated, using it for equal SSO behaviour on iOS 5 and 6.

UPDATE

Or is it possible to upload a photo with access token substitution? Using page access token instead of user access token. If yes, how can I get page access token programmatically without forcing user to log in as page administrator?

What would you advise me to do?
Thanks!

BR. Eugene.


回答1:


https://developers.facebook.com/docs/reference/api/page/#photos says,

“You can post photos to a Page's Wall by issuing an HTTP POST request to PAGE_ID/photos with the publish_stream and manage_pages permissions […]”

Sounds like a “normal” user is not allowed to post images to a page’s wall via the API.



来源:https://stackoverflow.com/questions/12687144/posting-a-photo-to-facebook-fan-page-as-user-ios-facebook-sdk-3-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!