Allow a user to post an invite to play an iOS app onto a friends Facebook wall?

My iOS app allows people to log in using Facebook, and automatically checks to see which of your friends are currently registered as using the app. All of your friends who are not currently using the app are in an "invite" list, in much the same way that DrawSomething has a 'play' and an 'invite' list of friends.

Regardless of whether you invite or play, a challenge is stored in the database ready for whenever your friend logs in.

Where I'm stuck is trying to work out how I would allow a user to post onto their friends wall. My php code already works out whether or not they are registered so from there I would simply need to post to 'Friend B's wall. I haven't been doing php for particularly long, and I've found that the Facebook code I've dealt with elsewhere isn't as self-explanatory as other sdk's etc.

I'm not really sure where to begin, as all of the Facebook "information gathering" i.e. friends user id is done in the app itself. I can pass this to the php code easily enough, but then I'm not sure how to use that to post onto their wall. I would assume that since the server is not logged into User A's Facebook account that it would need to do this somehow before it is allowed to post to their friend's wall, but I don't want the user to have to log in again in order to do this. Given that DrawSomething allows you to invite via Facebook I know it's possible, but I have no idea how to do it.

To sum up:

It's an iOS app, and I want users to be able to invite their friends by posting onto the friends Facebook wall.

If anyone can point me in the right direction I'd be extremely grateful.

Answers


OK so after battling with this for some time and looking high and low without any luck, I managed to stumble across how to do this today.

I'll update it here so anyone else who is struggling can see:

//using long longs to make sure the really long facebook ID's
//don't exceed integer limits

- (void)inviteUsingFacebook:(long long)facebookID
{
    NSString *numStr = [NSString stringWithFormat:@"%llu", facebookID];    
    NSString *desc = @"Download the app NOW from the App Store to play with ";
    desc = [desc stringByAppendingString:facebookNameStore];



NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"_YOUR_APP_ID_GOES_HERE", @"app_id",
                               @"YOUR_LINK", @"link",//most likely you will put itunes link here
                               @"FRIENDS_ID", @"target_id",//facebook id number of person you want to send to
                               @"http://URL_TO_IMAGE_YOU_WANT_TO_APPEAR_IN_WALL_POST.jpeg", @"picture",
                               @"YOUR APP NAME", @"name",
                               @"THIS IS AN INVITE EXAMPLE!", @"description",
                               nil];


[facebook dialog:@"stream.publish" andParams:params andDelegate:self];

}

And that's it!

I put this into my AppDelegate class, and call it when I hit my invite button - job done!

One thing to note is that this does result in a pop-up dialog which allows the user to add their own message, which personally I think is a good thing.


Need Your Help

Wrong value default ENUM Mysql type

php mysql database enums

as i see every where even in here :

Changing content of a fancybox with ajax

javascript jquery fancybox fancybox-2

I have a link in my menu that opens up a fancybox with some ajax contents. This box contains links, like a menu for the data shown in the fancybox. I would like to be able to click these links and ...