Php “错误”;需要在“中抛出上载文件”;来自Facebook图形API
我正在尝试制作一个脚本,自动将图片发布到我的三个粉丝页面 以下是脚本:Php “错误”;需要在“中抛出上载文件”;来自Facebook图形API,php,facebook-graph-api,Php,Facebook Graph Api,我正在尝试制作一个脚本,自动将图片发布到我的三个粉丝页面 以下是脚本: $facebook = new Facebook(array( 'appId' => $fbconfig['appid'], 'secret' => $fbconfig['secret'], 'fileUpload' => true, )); if($_GET["postType"] == "picture"){$type = "picture";} else {$type = "link";
$facebook = new Facebook(array(
'appId' => $fbconfig['appid'],
'secret' => $fbconfig['secret'],
'fileUpload' => true,
));
if($_GET["postType"] == "picture"){$type = "picture";}
else {$type = "link";}
// Download the picture, if $type == picture.
if($type == "picture")
{
$tempFileName = $_SERVER['DOCUMENT_ROOT'].'/TemporaryFiles/';
$tempFileName .= uniqid().'_'.basename($_GET["pictureUrl"]);
// Check if content retrieval is successful :D
if($imgContent = @file_get_contents($_GET["pictureUrl"]))
{
@file_put_contents($tempFileName,$imgContent);
}
}
foreach($pageIDs as $index=>$item)
{
$fbconfig['pageid'] = $item;
$facebook->setFileUploadSupport(true);
if($type == "picture")
{
$args = array(
'access_token' => $pageAccessTokens[$index],
'message' => $_GET["message"],
'source' => '@' . realpath($tempFileName),
);
$post_id = $facebook->api("/" . $albumIDs[$index] . "/photos","post",$args); // Post made :)
}
else if($type == "link")
{
$args = array(
'access_token' => $pageAccessTokens[$index],
'message' => $_GET["message"],
'link' => $_GET["linkUrl"],
'picture' => "",
);
$post_id = $facebook->api("/$pageid/feed","post",$args); // Post made :)
}
}
if($type == "picture")
{
unlink($tempFileName);
}
它抛出了以下错误:
未捕获的OAutheException:(#324)需要抛出上载文件
我试过调试它,但不知道它出了什么问题。如果有人能提供帮助,我们将不胜感激。您需要将照片上传添加到您请求的范围以上传图像
array('scope' => 'user_status,publish_stream,user_photos','photo_upload')
您需要将照片上传添加到您请求的范围以上传图像
array('scope' => 'user_status,publish_stream,user_photos','photo_upload')
在$facebook->api('/me')后面添加此代码
$this->facebook->setFileUploadSupport(true) 将其放在$facebook->api('/me')后面的代码中
$this->facebook->setFileUploadSupport(true) 调试代码时,“@”错误抑制运算符没有帮助。首先从
文件内容的两个实例中删除它。还有,你能告诉我你在哪里被卡住了吗?例如,您是否确保$type==“picture”
?您是否从Facebook API调用中获得$post\u id
?调试代码时,“@”错误抑制运算符没有帮助。首先从文件内容的两个实例中删除它。还有,你能告诉我你在哪里被卡住了吗?例如,您是否确保$type==“picture”
?您是否从Facebook API调用中获得$post\u id
?