在活动墙上发布图片和链接
问题描述:
有没有办法在活动墙上发布图片和链接?目前我只能发布状态(消息)。在用户的墙上没有这样的问题。我尝试了新的Graph API以及旧的REST API('stream.publish'方法),但没有成功(使用PHP SDK)。 预先感谢您。在活动墙上发布图片和链接
我使用的图形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);
正如我上面提到的,这两个是,如果我在用户的墙上发布工作。在事件的墙上发布状态消息,仅显示“消息”参数的内容。
答
我有同样的问题。活动墙贴仅显示为文字信息,无法通过任何API向活动墙发布“链接”或“帖子”。 相同的帖子在用户墙上或事件墙上显示不同。 行为可以在这里测试: http://developers.facebook.com/docs/reference/rest/stream.publish/ 只需填写表单并将相同的消息与有效的附件一次发送到用户墙,一次使用目标标识(对于事件)并查看差异。 这种行为没有记录,谷歌也没有提供太多帮助。 任何解决方法或解释将不胜感激。
这里是一个演示附件(在用户墙工作):
{
"name": "Test name",
"href": "http://www.google.com",
"description": "Test Desc",
"media": [
{
"type": "image",
"src": "(any image)",
"href": "http://www.google.com"
}
]
}
你能分享你尝试过什么(代码)? – ifaour
谢谢你的回应。我添加了我正在使用的代码。 –