【问题标题】:How to Post on FB app users wall through API code如何通过 API 代码在 FB 应用用户墙上发帖
【发布时间】:2013-03-05 10:44:11
【问题描述】:

我创建了一个 facebook 应用程序,需要在所有用户 FB WAll 上发帖,他们已授权应用程序代表那里发帖。

即在某处组织的新活动,因此通过应用,管理员可以在每个应用用户 FB 墙上发布有关该活动的信息。

我使用的是 Graph API,但它不起作用。

任何指针/指导将不胜感激。

谢谢

【问题讨论】:

  • 你在什么平台上工作,js还是php??
  • 在我的网站上使用 php
  • 检查更新的答案

标签: facebook facebook-graph-api post


【解决方案1】:

您必须使用参数进行 api 调用才能在用户墙上发布。

编辑:

这是下面的链接示例,并带有一些解释:

<?php
 $attachment = array(
'message' => 'this is my message',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'http://mylink.com',
'description' => 'this is a description',
'picture' => 'http://mysite.com/pic.gif'
);
?>
$result = $facebook->api('/me/feed/', 'post', $attachment);

$attachment 数组包含墙帖的参数,$facebook-&gt;api('/me/feed/','post',$attachment); 进行调用并将结果返回到$result

您可以在这里找到来源:How do you post to the wall on a facebook page (not profile)

【讨论】:

  • 请提供示例代码并说明其工作原理,而不是示例链接。您可以将其发布在评论中,而不是答案。
【解决方案2】:

在 JS SDK 中发布到用户墙:

var body = 'Status Test';
FB.api('/me/feed', 'post', { message: body }, function(response) {
   if (!response || response.error) {
       alert('Error occured');
   } else {
       alert('Post ID: ' + response.id);
   }
});

[编辑]
在 PHP 中

 $ret_obj = $facebook->api('/me/feed', 'POST',
                array(                      
                  'message' => 'Posting with the PHP SDK!'
             ));

【讨论】:

    猜你喜欢
    • 2012-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多