Facebook status post

Discussion in 'iOS Programming' started by idelovski, Aug 31, 2013.

  1. idelovski, Aug 31, 2013
    Last edited: Aug 31, 2013

    idelovski macrumors regular

    Sep 11, 2008
    What would be the easiest way of posting to Facebook these days on iOS 5 or better?

    I need to post a short message like "Hello world!", a link like "http:www.apple.com" and an image link, like "http://www.apple.com/logo.png"

    I have downloaded Facebook SDK and there are several issues with it. In theory we can post via facebook app, iOS integration or via dialogs. In practice, the code they provided in the example (HelloFacebookSample) it crashes on third option, second option does not have the param for image link and the first option is stuborn reporting the error that my application is not registered with Facebook.

    Well, it is as the second option lets me post the text but I can't attach the link to an image. And after some googling arround, I managed to fix the crash in the third option, but that option supports only text messages.

    In short, posting via FB app lets me post text, link and the image, but fails for unknown reason. Second option has the link and text params, no image link - instead I can only post the image data. Maybe I should download the image first and then post it with this method?! Third option has only s single string param, but does not work on my iPod with iOS 5.

    So what should I do? Go back to the way I did it few years ago, all on my own via Graph API and JSON? Is there a better way that works?

    Link to the code I'm referring to: HFViewController.m
  2. xArtx, Aug 31, 2013
    Last edited: Aug 31, 2013

    xArtx macrumors 6502a

    Mar 30, 2012


    Seems the one I followed is down now, but still works.
    Had to register the App at the Facebook end, as well as allowing it access to your personal
    account the way everyone has to.

    It was going to be the way I announced my own Apps on FB until they depreciated game posts
    on the news feed. Now it only shows up on your own wall.
  3. idelovski thread starter macrumors regular

    Sep 11, 2008
  4. ArtOfWarfare macrumors G3


    Nov 26, 2007
    I would like to point out that iOS 5 is being used on fewer than 0.1% of iPhones.
  5. Tander macrumors 6502a


    Oct 21, 2011
    Johannesburg, South Africa
    Out of interest - where do you get that stat from and are there similar stats for other iOS versions?
  6. ArtOfWarfare macrumors G3


    Nov 26, 2007
    The stat I'd given was from Chitika, and was last updated in March. They showed that iPads were much less likely to have the latest version of iOS.

    I just found this from Apple, which is probably even more accurate and current (although they break out a lot fewer numbers than Chitika.)

  7. idelovski, Sep 2, 2013
    Last edited: Sep 2, 2013

    idelovski thread starter macrumors regular

    Sep 11, 2008
    So zero point one was a bit of an overstatement...


    So after some investigation seems like both SLComposeViewController and UIActivityViewController wouldn't let me do what I want - post link, image link and a message.

    But, experimenting with all that stuff brought me to this:

    NSMutableDictionary  *fbArguments = [NSMutableDictionary dictionary];
    [fbArguments setObject:@"http://www.apple.com" forKey:@"url"];
    [fbArguments setObject:sendString forKey:@"message"];
    [fbArguments setObject:imageLink forKey:@"picture"];
    [fbArguments setObject:@"MyFancyApp" forKey:@"name"];
    [FBRequestConnection startWithGraphPath:@"me/feed"
                          completionHandler:^(FBRequestConnection  *connection, id result, NSError *error) {
                             [self showAlert:sendString result:result error:error];
    And as a bonus - if I use ios integration, I get "via iOS" flag, now I have "via MyFancyApp".
  8. xArtx macrumors 6502a

    Mar 30, 2012
  9. idelovski, Sep 4, 2013
    Last edited: Sep 4, 2013

    idelovski thread starter macrumors regular

    Sep 11, 2008
    But iOS 5 isn't really an issue here, at least isn't any more.

    The integrated posting does not let me specify the params I want (well, actually the params my clients want). They have this android version and that application sends its link, image link (as picture param), description param (and not the message, as the message is supposed to be entered by the user) and the "integrated" solution does not allow these.

    On top of that, it puts the "via iOS" mark and they want the name of the application as the source of the post.

    As usual, first you need something that barely woks, then your appetite increases and you want something that completely solves the problem.

    Now I wonder why is SDK on some devices using web dialog and Safari on others, all with exactly the same code. Looks like I need to look inside of the source code of the SDK!?
  10. xArtx macrumors 6502a

    Mar 30, 2012
    I haven't tried the integrated iOS 6 one,
    but the last tutorial sample lets you specify the App name,
    and user typing a message.
    It might be a hard coded string in the sample (can't remember),
    but if not, I linked it to a text box with keyboard.
    The other information in the pic is automatically populated with data from core location & media player.

  11. idelovski thread starter macrumors regular

    Sep 11, 2008
    Using integrated fb is As easy as sending mail, just like that. But if you want anything different, youre out of luck.

    Fortunately, it all works now as my clients wanted, at least when I login with my fb account. I've heard about some problems people have later when regular, non-dev, non-admin accounts can't sign in to your app for some reason, but I didn't come to that thus far.
  12. xArtx macrumors 6502a

    Mar 30, 2012
    Can't add to that. Mine is only posted from me to my own FB account.
    I would like to have believed it would be fine for the App Store,
    but I haven't used it.
    Perhaps I should test it with another FB account on another provisioned phone.


Share This Page