Reputation: 357
I've just solved the problem with posting on facebook's wall programmatically using Facebook iOS sdk. It is completely working in my application. Here's the part of code:
NSString *messageString=@"test message";
FBRequest *request=[[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:@"me/feed" parameters:[NSDictionary dictionaryWithObject:messageString forKey:@"message"] HTTPMethod:@"POST"];
Now I need to post not only the text message on facebook's wall. I need to post this:
Here are the parameters which I should use to make my post look similar http://developers.facebook.com/docs/reference/rest/stream.publish/
Help me please to make tether values with parameters (message, link, caption etc.).
The very best answer would be NSDictionary
object which I can pass to my FBRequest
init method as a parameters
argument.
Thanks you for your attention.
Upvotes: 0
Views: 871
Reputation: 18551
This is the code I use to post to Facebook for something very much like your picture.
SBJSON *jsonWriter = [SBJSON new];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
attachmentTitle, @"name",
attachmentLink, @"href",
attachmentCaption, @"caption",
attachmentDescription, @"description",
nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
[postContent setObject:attachmentStr forKey:@"attachment"];
[postContent setObject:textView.text forKey:@"message"];
[FB requestWithMethodName:@"stream.publish" andParams:postContent andHttpMethod:@"POST" andDelegate:self];
Upvotes: 1