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

    Joined:
    Sep 11, 2008
    #1
    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

    Joined:
    Mar 30, 2012
    #2
    http://www.techotopia.com/index.php...ation_Tutorial_using_UIActivityViewController

    [​IMG]

    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

    Joined:
    Sep 11, 2008
  4. ArtOfWarfare macrumors 604

    ArtOfWarfare

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

    Tander

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

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #6
    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.)

    https://developer.apple.com/devcenter/ios/checklist/
     
  7. idelovski, Sep 2, 2013
    Last edited: Sep 2, 2013

    idelovski thread starter macrumors regular

    Joined:
    Sep 11, 2008
    #7
    So zero point one was a bit of an overstatement...

    EDIT:

    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:

    Code:
    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"
                                 parameters:fbArguments
                                 HTTPMethod:@"POST"
                          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

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

    idelovski thread starter macrumors regular

    Joined:
    Sep 11, 2008
    #9
    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

    Joined:
    Mar 30, 2012
    #10
    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

    Joined:
    Sep 11, 2008
    #11
    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

    Joined:
    Mar 30, 2012
    #12
    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