Reputation: 11
I am posting to the facebook wall from an iPhone app. It works well when I just sends a message, but when I try to add a link the message is not posted on Facebook.
Code:
NSString *link = @"http://www.foo.com";
NSString *linkName = @"Bar";
NSString *linkCaption = @"Foo Bar";
NSString *linkDescription = @"Fooooooo Bar";
NSString *message = @"Message";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, @"api_key",
message, @"message",
linkName, @"name",
linkDescription, @"description",
link, @"link",
linkCaption, @"caption",
nil];
[_facebook requestWithGraphPath: @"me/feed"
andParams: params
andHttpMethod: @"POST"
andDelegate: self];
It is when I add the link and caption to the params dictionary that FaceBook will not post on the wall. I don't even get an error in (void) request: (FBRequest *) request didFailWithError: (NSError *) error
so it seems Facebook thinks the request is ok.
Upvotes: 1
Views: 6649
Reputation: 1715
Use This.This one is working fine for me.
NSString *graphPath = @"me/feed";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
self.link,@"link",
self.url,@"picture",
self.message,@"name",
@"Write_Captioon",@"caption",
self.description,@"description",
/*@"Facebook Dialogs are so easy!",@"message",*/
nil];
[[FBRequestWrapper defaultManager] sendFBRequestWithGraphPath:graphPath params:params andDelegate:self];
Check your url too,may be that url is not of proper form.I didn't face this kind of problem in Facebook but in case LinkedIn when my url has "=",the post was not being shared,but was successfully sharing with other urls.Hope this will help you.
Upvotes: 0
Reputation: 81
I had the same problem but with a PHP app and solved it by getting a page access token. Once you have a user access token go to:
https://graph.facebook.com/me/accounts?access_token=USER_ACCESS_TOKEN
Within the returned data find the page's name and and its corresponding access token. Using the page access token allowed my links to be posted.
Upvotes: 0
Reputation: 750
If you are using FBConnect
then use this methods every thing is post on FB wall.
- (void)postToWall
{
FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"Facebook Connect for iPhone\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\",\"caption\":\"Caption\",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}"];
[dialog show];
}
Upvotes: 0
Reputation: 653
I'm not sure what your problem is, since everything looks fine, but this might help you troubleshoot: http://developers.facebook.com/docs/reference/rest/stream.publish/
Try posting your message via form on that page and see what Facebook tells you. If there is a problem, you'll see an error message.
To post a link you need to add an attachment with this syntax:
{ "href": "http://www.fantasy-fan.org", "name": "test", "caption": "test2", "description": "test3", "media": [{ "type": "image", "src": "http://dragontest.fantasy-fan.org/images/dwarf.jpg", "href": "http://www.fantasy-fan.org" }]}
Upvotes: 0
Reputation: 1061
For showing links on FB, u could make use of actionLinks.
delgates as
dialog.actionLinks = @"[{\"text\":\"See My App here!\",\"href\":\"http://www.facebook.com/developers/apps.php?app_id=178257532217623&ret=2/\"}]";
this will show ur links on right side of the post
Upvotes: 0
Reputation: 61228
You may want to check out ShareKit. It's a pretty well-maintained open-source library for interfacing with the various social web services and leaves maintaining API compatibility with the ShareKit community.
Upvotes: 1
Reputation: 16543
I just posted the Link in FB with the use of attachment...
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"Visit My Site", @"name",
@"http://www.mysite.com", @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Your Message",@"message",
attachmentStr,@"attachment",nil];
Upvotes: 0