簡體   English   中英

PHP:將圖片-僅鏈接-發布到Facebook牆

[英]PHP: Post image -link only- into Facebook wall

我正在嘗試使用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));

試試這個:

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

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

請享用 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM