简体   繁体   English

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

[英]Facebook API - Post photo and link to wall simultaneously

Is it possible to post image and link together? 是否可以发布图像并链接在一起? Here is my code : 这是我的代码:

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.');
}

Without 'link' everything is ok, but if I insert link into array i got an error : Notice: Undefined variable: postResult in.. 没有'link'一切都很好,但是如果我将链接插入数组中,则会出现错误: Notice: Undefined variable: postResult in..

Is there something wrong with my code? 我的代码有问题吗? Please help, Thank you. 请帮忙,谢谢。

If you read the documentation , the link parameter is- 如果您阅读该文档 ,则链接参数为-

A link to the photo on Facebook (that you wish to upload) 指向Facebook(您要上传)上的照片的链接

But you are using it in another way, to share link along with the photo- which is not possible. 但是您以另一种方式使用它,无法与照片共享链接,这是不可能的。 For sharing a link on wall you have to use Feed instead. 要在墙上共享链接,您必须改用Feed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM