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

正如我上面提到的,這兩個是,如果我在用戶的牆上發佈工作。在事件的牆上發佈狀態消息,僅顯示「消息」參數的內容。

+0

你能分享你嘗試過什麼(代碼)? – ifaour

+0

謝謝你的迴應。我添加了我正在使用的代碼。 –

回答

0

我有同樣的問題。活動牆貼僅顯示爲文字信息,無法通過任何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"   
      } 
       ] 

}