Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

idelovski

macrumors regular
Original poster
Sep 11, 2008
235
0
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
 
Last edited:
http://www.techotopia.com/index.php...ation_Tutorial_using_UIActivityViewController

FB_Hackpost_zps9bece5c5.png


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.
 
Last edited:
Out of interest - where do you get that stat from and are there similar stats for other iOS versions?

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/
 
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".
 
Last edited:
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!?
 
Last edited:
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.


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!?
 
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.
 
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.

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.