Post a photo to a page for iOS

2020-08-01 05:36发布

问题:

I am trying to post a photo to a page that the user does not own. Note that all solutions that I found from other discussion threads require the user to be administrative and get the access_token of a page with *manage_pages* permissions.

However, what I want to do is different: Using iOS SDK to upload an image to a page, which has a setting that people can upload images to it.

I try several ways, but none of them works.

Here is how I get permissions

NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"photo_upload",
                            @"share_item",
                            @"status_update",
                            @"manage_pages",
                            @"user_likes",
                            @"publish_stream", 
                            nil];
    [fb authorize: permissions];

Here are the codes for uploading the image

NSString *uri = [NSString stringWithFormat: @"%@/photos", FBPageId];
[fb requestWithGraphPath: uri
               andParams: params
           andHttpMethod: @"POST"
             andDelegate: self];

It kept posting the image to the user's album, which is not what I want.

I will really appreciate if anyone knows how to do it. Thank you!

回答1:

I have two potential workarounds for you to try out:

  1. Post the picture to the pages feed rather than to the {pageid}/photos.

  2. Collect the albums for that page {pageid}/albums. Now with the correct album id, post the picture to {albumId}/photos.