Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Posting Photo to facebook fan page via iOS app by regular non-admin users

I am trying to post a photo to my apps facebook fan page and to the users wall also. I have been successful to post the photo on the users wall, but failed to post it in the fan pages wall. (The user is not necessarily an admin or page owner, just the regular users. As the fan page has the option of anyone can post to it, it is not mandatory for the user to even like the page first. Right?)

After googling a while, I found this answer. According to it, I need an access_token of the fan page and an album_id to do so. But I can't find any clue about how to get them. So far I have tried this code:

if ([appDelegate.facebook isSessionValid]) 
    {
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       resultImage, @"picture",
                                       nil];

        [appDelegate.facebook requestWithGraphPath:@"me/photos"
                                         andParams:params
                                     andHttpMethod:@"POST"
                                       andDelegate:self]; // to post on users wall, works fine

         NSString *path = [NSString stringWithFormat:@"my/accounts /fan_page_id?fields=access_toke/photos"];
        [appDelegate.facebook setAccessToken: FACEBOOK_ACCESS_TOKEN];

        [appDelegate.facebook requestWithGraphPath:path andParams:params andHttpMethod:@"POST" andDelegate:self]; // to post on fan page wall,  this doesn't work
    }

Can anyone help me with this? What am I missing here? Thanks in advance.

UPDATE

According to this answer, a regular user can not post a photo to the fan pages wall from an iOS app but can share the photo on it. Now, my question is, how do I accomplish posting the photo on the users wall and share it on the fan page wall at the same time? Is it possible? How do I share the photo on the fan page wall?

UPDATE 2

This answer and the question says that the regular users can post to a fan page wall via news feed, so i modified my code like this:

if ([appDelegate.facebook isSessionValid]) {
        NSMutableDictionary *page_params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       @"fan_page_id", @"to",
                                       @"Test", @"name",
                                       @"Test", @"caption",
                                       resultImage, @"picture",
                                       nil];
        [appDelegate.facebook   dialog:@"feed"
                                andParams:page_params
                                andDelegate:self];

}

But, I keep getting this ridiculous error message and the app crashes:

-[UIImage length]: unrecognized selector sent to instance 0x24d110
2012-06-06 19:59:03.114 app_name[2739:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0x24d110'

What should I do now?

At this point after waiting so long, the question comes in my mind is, is this even possible? If so, how do I accomplish this task? And if not, then what are the alternatives? Please help.

Update 3

Just found that there is a known bug in both iOS sdk and the javascript sdk for posting dialogs in fan page wall. Is this true for image upload too? If anyone has a solution to avoid this bug, please help.

like image 215
Shabib Avatar asked Jun 06 '12 11:06

Shabib


1 Answers

This isn't currently (June 2012) possible because of a bug in the API: https://developers.facebook.com/bugs/206254392780441 has the details.

One workaround is to post to the /feed connection of the page and attach an image to the feed story. That image won't be displayed as large as a proper photo upload, but should work OK.

That bug means that posting to the /PAGE_ID/photos connection of a Page using a User access_token will incorrectly upload the photo to the user's /photos connection instead.

Posting to a page's /photos connection will work as expected when using the Page's access_token; the photo will appear on the page's photos page, on the page's timeline, and attributed to the Page itself (i.e 'from' the page)

If your app is specifically for adding content to a page, and has a server-side component, another workaround to get the photos from a user onto the page is to have the users supply a photo to you via your own interface (i.e upload it from the user's device to your server), and use one of the page admins' access_tokens to get a Page access_token and make the upload that way.

like image 80
Igy Avatar answered Nov 16 '22 19:11

Igy