Reputation: 55554
I have the demo facebook app and without any modification this is the code:
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
@"Always Running",@"text",@"http://itsti.me/",@"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"a long run", @"name",
@"The Facebook Running app", @"caption",
@"it is fun", @"description",
@"http://itsti.me/", @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Share on Facebook", @"user_message_prompt",
actionLinksStr, @"action_links",
attachmentStr, @"attachment",
nil];
[_facebook dialog:@"feed"
andParams:params
andDelegate:self];
This however doesn't post a link, it fact it only posts a normal status which the user enters.
How do I post a link using the Facebook SDK on an iPhone, using the newest version of the facebook (the graph api?)
I can't find anywhere on how to post a link from an iphone app using the facebook sdk.
Upvotes: 2
Views: 5445
Reputation: 55554
[_facebook dialog:@"feed"
andParams:params
andDelegate:self];
The problem is that facebook updated the API on the web, but not the SDK, so while @"feed"
is the correct name for the dialog after the API update, the old name stream.publish
is still used in the code. Therefore to get the params to work and actually be part of the message you have to use:
[_facebook dialog:@"stream.publish"
andParams:params
andDelegate:self]
Also see iPortable's answer for another mistake by facebook.
Upvotes: 7
Reputation:
how can this be? you create a NSArray but put it in an NSDictionary:
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
@"Always Running",@"text",@"http://itsti.me/",@"href", nil], nil];
// EDIT 2: ok as mentioned it should be NSArray* actionLinks = …
Upvotes: 2