获取致命错误未捕获CurlException:26:无法打开文件

时间:2011-12-19 23:09:23

标签: php facebook image facebook-php-sdk

我正在尝试使用PHP的GD库创建我的朋友的动态图像,我需要将其上传到我的朋友个人资料但我一直收到错误 致命错误:未捕获CurlException:26:无法打开第820行/home/p170r760/public_html/myfbapps/mysupporters/base_facebook.php中抛出的文件“

$image = imagecreatetruecolor(500, 500);
$orange = imagecolorallocate($image, 0xFF, 0x8c, 0x00);
$bg = imagecreatefromjpeg('app2_bg.jpg');
imagesettile($image, $bg);
imagefilledrectangle($image, 0, 0, 499, 499, IMG_COLOR_TILED);
$font_file = 'TURNBB__.TTF';
imagefttext($image, 20, 0, 105, 50, $orange, $font_file, 'My Top Supporters');
for($i=0;$i<5;$i++) {
imagefttext($image, 13, 0, 10, (100+($i*80)), $orange, $font_file,'Rank #'.($i+1).':');
imagefttext($image, 13, 0, 250, (100+($i*80)), $orange, $font_file, $mutual_friends[$i]  ['name']);
$frnd_pic=$facebook->api('/'.$mutual_friends[$i]['id'].'?fields=picture&type=square');
$frnd = imagecreatefromstring(file_get_contents($frnd_pic['picture']));
imagecopymerge($image,$frnd,150,(80+($i*80)),0,0,50,50,100);
$tags[] = array(
       'tag_uid' => $mutual_friends[$i]['id'], /*Current user’s id*/
       'x' => (150/5),
       'y' => ((80+($i*80))/5)
   );  
}
imagepng($image, '/img/' . $me['id'] . '.png');
$pic = realpath("/home/p170r760/public_html/myfbapps/mysupporters/" . $me['id'] .  '.png');
$facebook->setFileUploadSupport("http://" . $_SERVER['SERVER_NAME']);
$pic_id = $facebook->api('/me/photos', 'POST', array('message' => 'My Top Supporters',
'source' => '@' . $pic,
'tags' => $tags));
 imagedestroy($image);
 ?>

任何人都可以告诉我哪里出错了?

2 个答案:

答案 0 :(得分:1)

PHP SDK 3.1在行

中不支持您使用的setfileUploadSupport API
 $facebook->setFileUploadSupport("http://" . $_SERVER['SERVER_NAME']);

改变它

 $facebook->setFileUploadSupport(true)

答案 1 :(得分:0)

您正在/img/{$me['id'}.png保存文件,但尝试从其他路径上传文件...

/home/p170r760/public_html/myfbapps/mysupporters/{$me['id']}.png/img/{$me['id'}.png

不同