6

I'm trying to publish a link to the user's wall on Facebook after he has already logged in using the new Facebook iOS SDK.

I want the link to behave as if the user posted it from his account. For example, if I post this link on my Facebook wall: http://www.apple.com/, I won't see the link. What I'll see is an image, a caption with the actual url and a short description. But when I publish this same link from my app, all I see is the link itself.

How can I publish this url through my app so that what will eventually appear on the user's wall is the formatted message as it would appear if he would have posted it from his account on the pc, and not just the link itself as a string?

Thanks,

0

2 Answers 2

28

EDIT: The code below is for an OLD version of the FB SDK

Check here for a more up to date answer that may help Facebook sdk post on wall on iPhone app

OLD POST:

From http://developers.facebook.com/docs/reference/dialogs/feed/

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
  kAppId, @"app_id",
  @"http://developers.facebook.com/docs/reference/dialogs/", @"link",
  @"http://fbrell.com/f8.jpg", @"picture",
  @"Facebook Dialogs", @"name",
  @"Reference Documentation", @"caption",
  @"Dialogs provide a simple, consistent interface for apps to interact with users.", @"description",
  @"Facebook Dialogs are so easy!",  @"message",
  nil];

[_facebook dialog:@"feed" andParams:params andDelegate:self];
6
  • I would, but I didn't ask the question. But yes, it did help me! (Upvoted, with thanks.) May 10, 2011 at 15:21
  • I can't seem to set the parameter to NOT show an image preview from my link, any thoughts ?
    – Daniel
    Aug 16, 2011 at 14:54
  • Do you have any idee why the: @"some_facebook_id", @"to" does not work for publishing to another user wall? I already set the permisions and the authorize is already done...
    – Daniel
    Dec 10, 2011 at 14:52
  • I'm trying to put linefeeds in the message element... struggling. For example, in this post, each of the words, "facebook dialogs are so easy" would have their own line... I've tried \n and \r to no avail. I've tried properties with each line as a json element - this seems to work at first but then you notice that the lines are posted to facebook from the bottom of the json object to the top (reverse order). argh.
    – phil
    Apr 25, 2012 at 3:30
  • This doesn't work now, since the "Facebook" object, and the "dialog: andParams: andDelegate:" method don't exist anymore
    – Plot
    Dec 4, 2012 at 16:23
0

You need to use FBStreamDialog for this. I do not have the exact code. Try this:

FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = @"What's in your mind?";
dialog.attachment = @"{\"name\":\"Apple URL","
"\"href\":\"http://www.apple.com\","
"\"caption\":\"App Name\",\"description\":\"Posting link Test\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://www.apple.com\","
"\"href\":\"http://www.apple.com\"}],"
"\"properties\":{\"another link\":{\"text\":\"Apple home page\",\"href\":\"http://www.apple.com\"}}}";
[dialog show];
1
  • But this is using the old Facebook Connect interface. I don't think this will work on the new Facebook iOS SDK.
    – Rony Rozen
    Dec 8, 2010 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.