1

我正在从 iPhone 应用程序发布到 Facebook 墙上。当我只发送一条消息时效果很好,但是当我尝试添加链接时,消息不会发布在 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 似乎认为请求没问题。

4

7 回答 7

1

您可能想查看ShareKit。它是一个维护良好的开源库,用于与各种社交网络服务交互,并保持与 ShareKit 社区的 API 兼容性。

于 2011-03-03T15:06:19.437 回答
0

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];
于 2011-03-03T13:49:53.653 回答
0

为了在 FB 上显示链接,你可以使用 actionLinks。

委托为

dialog.actionLinks = @"[{\"text\":\"See My App here!\",\"href\":\"http://www.facebook.com/developers/apps.php?app_id=178257532217623&ret=2/\"}]";

这将在帖子右侧显示您的链接

于 2011-03-03T18:15:54.293 回答
0

如果您正在使用,请FBConnect使用此方法,每件事都张贴在 FB 墙上。

- (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];

 }
于 2012-05-07T10:29:57.673 回答
0

我不确定您的问题是什么,因为一切看起来都很好,但这可能会帮助您解决问题:http: //developers.facebook.com/docs/reference/rest/stream.publish/

尝试通过该页面上的表单发布您的消息,看看 Facebook 告诉您什么。如果出现问题,您将看到一条错误消息。

要发布链接,您需要使用以下语法添加附件:

{ "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" }]}
于 2011-03-08T20:20:15.260 回答
0

使用这个。这个对我来说很好用。

 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];

也检查你的网址,可能是网址格式不正确。我在 Facebook 中没有遇到这种问题,但是如果我的网址有“=”时,LinkedIn 帖子没有被分享,但被成功分享其他网址。希望这会对您有所帮助。

于 2013-09-10T09:45:27.150 回答
0

我有同样的问题,但使用 PHP 应用程序并通过获取页​​面访问令牌解决了它。获得用户访问令牌后,请转到:

https://graph.facebook.com/me/accounts?access_token=USER_ACCESS_TOKEN

在返回的数据中找到页面的名称及其相应的访问令牌。使用页面访问令牌允许发布我的链接。

于 2013-06-06T17:26:37.563 回答