2
有沒有辦法在活動牆上發佈圖片和鏈接?目前我只能發佈狀態(消息)。在用戶的牆上沒有這樣的問題。我嘗試了新的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);
正如我上面提到的,這兩個是,如果我在用戶的牆上發佈工作。在事件的牆上發佈狀態消息,僅顯示「消息」參數的內容。
你能分享你嘗試過什麼(代碼)? – ifaour
謝謝你的迴應。我添加了我正在使用的代碼。 –