iPhone App Send Facebook Message or Post to Friend

2019-08-05 14:07发布

问题:

Here is my current setup. I can click a button and post an image and a comment or news story directly to my wall, mainly just doing some simple FBConnect or ShareKit options.

I would like to expand this to something more complex and engrossing/useful. I would like to be able to take a comment or news story, and either send it in a message to someone on Facebook, or post it to any of my friend's walls.

I believe I will need to use Facebook Open Graph to accomplish this, but am unsure of where to begin. I do have an App setup in Facebook, though it is essentially just for the purpose of SSO with my apps. Could someone direct me to a good tutorial to do what I would like and/or guide me through getting my app set up in Facebook, and then some suggestions for integrating with iPhone?

回答1:

For posting on Friend's wall, you can use FB's graph api. Here you go with the minimal code snippet for publishing something on friend's wall:

NSMutableDictionary* params = [NSMutableDictionary dictionary];
[params setObject:@"Some text" forKey:@"user_message_prompt"];
[params setObject:@"another text" forKey:@"action_links"];
[params setObject:@"Yet another text" forKey:@"attachment"];
[params setObject:@"SOME FACEBOOK ID" forKey:@"target_id"];

//At some point you need to create the following Facebook instance

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