我试图使用Facebook Graph API将照片上传到Facebook粉丝页面,我能够上传照片,但它上传为一个小缩略图,我的主机名写在它旁边两次(即www。 myhost.comwww.myhost.com)
我需要上传原始大小的照片而不在其旁边写任何内容
我正在使用:
$params = array(
"access_token" => $access_token,
"picture" => "http://www.myhost.com/fb/Azkar-001.png",
);
$ret = $fb->api('/myID/feed', 'POST', $params);
感谢您的反馈,因为我是图API的新手
答案 0 :(得分:1)
常见错误是使用me/feed
,me/feed
目标并发布状态更新&将帖子链接到用户的流
要将照片上传到用户流/时间线,请使用me/photos
$ret = $fb->api('/me/photos', 'POST', $params);
等等,你还有另一个问题,即使用param picture
,为什么?
因为您要从网址上传,请将picture
替换为url
$params = array(
"access_token" => $access_token,
"url" => "http://www.myhost.com/fb/Azkar-001.png",
);
$ret = $fb->api('/me/photos', 'POST', $params);
答案 1 :(得分:0)
感谢Adam,HYG的完整代码:
<?php
require_once("facebook.php");
$access_token = "Add_Your_Access_Token_here";
$facebook = new Facebook(array(
'appId' => 'Add_Your_App_ID_Here',
'secret' => 'Add_Your_App_Secret_Here',
'fileUpload' => true, // I put this as False in my original program and this was the reason for my early issues
'cookie' => true // enable optional cookie support
));
$facebook->setFileUploadSupport(true);
$file = "@".realpath("001.png"); //Put the file path here
$args = array(
"message" => "Photo Caption'"
"access_token" => $access_token,
"image" => $file
);
$data = $facebook->api('/me/photos', 'post', $args); //This is the line that made everything working fine, thanks to Adam
if ($data) print_r("success");
?>