【问题标题】:Publish post with picture and link on event's wall在活动墙上发布带有图片和链接的帖子
【发布时间】:2011-09-25 14:51:06
【问题描述】:

有没有办法在活动的墙上发布带有图片和链接的帖子?目前我只能发布状态(消息)。在用户的墙上没有这样的问题。我已经尝试了新的 Graph API 以及旧的 REST API('stream.publish' 方法)但没有成功(使用 PHP SDK)。 提前谢谢你。

我用于 Graph API 的代码:

$attachment = array(
            'message' => 'my message',
            'name' => 'This is my demo Facebook application!',
            'caption' => "Caption of the Post",
            'description' => 'this is a description',
            'picture' => 'link to an image',
            'actions' => array(array('name' => 'See recipe',
            'link' => 'http://www.google.com'))
        );
$facebook->api('/'.$eventID.'/feed/','post',$attachment);

REST API 的代码:

$url = "https://api.facebook.com/method/stream.publish?".$access_token;

$attachment = array('name' => 'This is my demo Facebook application!',
   'href' => 'http://news.google.com',
   'description' => 'It is fun!',
   'media'=> array(array(
                  'type'=> 'image',
                  'src' => 'link to an image',
                  'href' => 'http://www.google.gr'))
   );

$params = array();
$params['message'] = "my message";
$params['attachment'] = json_encode($attachment);
$params['target_id'] = $eventID;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$result = curl_exec($ch);
curl_close($ch);

正如我上面提到的,如果我在用户的墙上发布,两者都可以工作。在活动的墙上发布一条状态消息,仅显示“消息”参数的内容。

【问题讨论】:

  • 你能分享你尝试过的(代码)吗?
  • 感谢您的回复。我添加了我正在使用的代码。

标签: php facebook-graph-api facebook-wall facebook-events facebook-rest-api


【解决方案1】:

我也有同样的问题。活动墙帖子仅以短信形式显示,无法通过任何 API 向活动墙发布“链接”或“帖子”。 相同的帖子在用户墙或活动墙上的显示方式不同。 可以在此处测试行为: http://developers.facebook.com/docs/reference/rest/stream.publish/ 只需填写表格并将带有有效附件的相同消息发布到用户墙一次,然后使用目标 ID(针对事件)发布一次,然后查看差异。 这种行为没有记录,谷歌也没有提供太多帮助。 任何解决方法或解释将不胜感激。

这是一个演示附件(在用户墙上工作):

 {     
     "name": "Test name",     
     "href": "http://www.google.com",    
     "description": "Test Desc",     
     "media": [         
            {
                  "type": "image",             
                  "src": "(any image)", 
                  "href": "http://www.google.com"        
            }
              ]

 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-07
    • 2014-04-19
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 2012-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多