2012-05-05 108 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); 

享受:)