我想通过图形api发布图像到用户的墙上。 我试图发布托管在我的服务器的图像,它工作正常。但是当我尝试发布本地文件时,它会给出以下错误。 未捕获的OAuthException:(#100)图片URL格式不正确。从本地机器发布图像到Facebook用户墙
我的代码如下所示
require_once "facebook-sdk/src/facebook.php";
$app_id = "23432423432";
$app_secret = "345345353553535353534534";
// Init facebook api.
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$urlTitle = 'my url';
$review = 'test desc';
//$picLocal = 'http://l.yimg.com/a/i/ww/met/yahoo_logo_in_061509.png';
$picLocal = '@' . realpath('/var/www/PixShare/a.jpg');
$attachment = array('message' => ' testing',
'description' => 'Review: ' . $review,
'access_token' => 'USER ACCESS TOKEN',
'picture' => $picLocal
);
if(!($sendMessage = $facebook->api('/me/feed/','post',$attachment))){
$errors= error_get_last();
echo "Facebook publish error: ".$errors['type'];
echo "<br />\n".$errors['message'];
请让我知道这是可能的。
您也可以上传照片作为多部分形式,而不是试图链接t o其网址 – Igy
您是否在'picture'=> $ _FILE ['tmp_name']中传递$ _FILE ['tmp_name']请问您能否解释一下。 –
我试过使用文件上传的形式,并设置'图片'=> $ _FILES [“文件”] [“tmp_name”] 也试过'源'=> $ _FILES [“文件”] [“tmp_name”] 仍然越来越同样的错误。 –