Facebook API - 发布照片并同时链接到墙壁

时间:2013-11-10 05:54:04

标签: php facebook facebook-graph-api facebook-php-sdk

是否可以发布图像并链接在一起?这是我的代码:

try {
$facebook->setFileUploadSupport(true);

if(!isset($userLink)){
   $postResult = $facebook->api(
                  '/'.$userGroupId.'/photos/',
                  'post',
                  array(
                     'message' => $userMessage,
                     'source' => '@'.$_FILES["source"]["tmp_name"] ));
}else{
   $postResult = $facebook->api(
                  '/'.$userGroupId.'/photos/',
                  'post',
                  array(
                     'message' => $userMessage,
                     'link' => $userLink,
                     'source' => '@'.$_FILES["source"]["tmp_name"] ));
  }
}
catch (FacebookApiException $e) {
    error_log('Could not post image to Facebook.');
}

没有'link'一切正常,但是如果我将链接插入数组我就会收到错误:Notice: Undefined variable: postResult in..

我的代码有问题吗?请帮忙,谢谢。

1 个答案:

答案 0 :(得分:0)

如果您阅读documentation,则链接参数为 -

  

Facebook上的照片链接(您要上传)

但是你以另一种方式使用它,与照片共享链接 - 这是不可能的。要在墙上共享链接,您必须改为使用Feed

相关问题