Search code examples
iphoneiosfacebookfeedfbconnect

FBConnect iOS: Post photo to feed with message every time


I am working on an iOS app that needs to post to either Twitter, or Facebook, or both, every N minutes. The post needs to include a photo and message. I have this woking fine for Twitter, however I'm running into some issues with FBConnect.

The only way I've found to post an image using the image data, rather than a link, is to post to /photos (graph API) and include a message parameter. Unfortunately, it seems that after the first post, subsequent posts either don't show up, or show up as "User added photo to album {app_name}", instead of the message and photo.

Here is my code:

    NSMutableDictionary* params = [NSMutableDictionary dictionary];
    [params setObject:message forKey:@"message"];
    if (image) {
        [params setObject:image forKey:@"picture"];
        [fb requestWithGraphPath:@"me/photos" andParams:params
                   andHttpMethod:@"POST"
                     andDelegate:self];
    } else {
        [fb requestWithGraphPath:@"me/feed" andParams:params
                   andHttpMethod:@"POST"
                     andDelegate:self];
    }

Is there a way to post an image to the feed directly so that the message and photo show up every time? The only way I could think of was to post a photo to the album and then make a second call to add a feed post with a link to the photo in it, but I'd really rather make just one call.


Solution

  • There's no way to do it directly. Your approach is good.