2012-05-05 59 views
0

我想使用PHP發佈到Facebook牆上。我發現這個代碼:PHP:發佈圖像 - 僅鏈接到Facebook牆

$args = array(
    'message' => $text, 
    'picture' => $link2picture 
); 

$this->_facebook->api('/me/feed/', 'post', $args); 

但它似乎不工作(它只顯示消息文本)。所以我的問題是,有什麼辦法只發布圖片,將其鏈接到一個頁面?我試圖避免將照片上傳到Facebook,並且我不想使用顯示左側對齊的小圖片的標準「共享鏈接」;我的想法只是顯示圖像縮略圖,可能是圖像之前或之後的描述,當用戶點擊該圖像時,他將被重定向到給定的頁面。這可以做到嗎?怎麼樣?

編輯:我也試過這個代碼,沒有成功:

$attachment = array(
'name' => $title, 
'caption' => 'The subtitle', 
'description' => $message, 
'media' => array(array(
    'type' => 'image', 
    'src' => $file_path, 
    'href' => $link 
)) 
); 
$this->facebook->api(array('method' => 'stream.publish', 'target_id' => $this->getUser(), 'attachment' => $attachment)); 

回答

0

就試試這個:

 
$attachment = array('message' => $message, 'access_token' => $token, 'picture' => $picture_path); 

$result = $facebook->api('/me/feed', 'post', $attachment); 

享受:)