从iPhone应用程序发布到Facebook墙的链接
我从iPhone应用程序发布到Facebook墙。当我只是发送消息时,它运行良好,但是当我尝试添加链接时,该消息不会发布在Facebook上。从iPhone应用程序发布到Facebook墙的链接
代码:
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];
这是当我添加了链接和标题给PARAMS字典,Facebook不会张贴在墙上。我甚至没有在(void) request: (FBRequest *) request didFailWithError: (NSError *) error
中发生错误,所以看起来Facebook认为请求没问题。
我只是张贴在FB中的链接与使用附件...
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];
为了显示FB上的链接,你可以使用actionLinks。
delgates作为
dialog.actionLinks = @"[{\"text\":\"See My App here!\",\"href\":\"http://www.facebook.com/developers/apps.php?app_id=178257532217623&ret=2/\"}]";
这将显示在乌拉圭回合后的右侧链接
我不知道你的问题是什么,因为一切都看起来不错,但是这可能会帮助您解决: http://developers.facebook.com/docs/reference/rest/stream.publish/
尝试通过表单页面上发布你的信息,看看Facebook的告诉你。如果出现问题,您会看到一条错误消息。如果您正在使用FBConnect
然后用这个方法每一件事情是在后墙上FB
{ "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" }]}
:
要发布你需要使用此语法添加附件中的链接。
- (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];
}
我有同样的问题,但与PHP应用程序,并通过获取页面访问令牌解决它。一旦你有一个用户访问令牌,请访问:
https://graph.facebook.com/me/accounts?access_token=USER_ACCESS_TOKEN
在返回的数据找到该网页的名称,及其相应的访问令牌。使用页面访问令牌可以发布我的链接。
使用这个。这个对我来说工作得很好。
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];
检查您的网址也可能是网址不正确form.I的没有面临这种问题了Facebook,但如果LinkedIn的时候我的网址有“=”,后没有被分享,但与其他网站成功共享。希望这会帮助你。
参数的字符限制是什么? – user3306145 2016-08-10 12:48:13
我已经看到这个方法用了很多,并尝试过,结果和我在第一篇文章中一样。此外,我无法在新Facebook API的文档中找到对“附件”的任何引用:http://developers.facebook。com/docs/reference/api/post/ – KIS 2011-03-03 14:22:03