0

I am trying to create a dynamic image of my friends using PHP's GD Library, and I need to upload this to my Friends Profile but I keep getting an Error Fatal error: Uncaught CurlException: 26: couldn't open file "" thrown in /home/p170r760/public_html/myfbapps/mysupporters/base_facebook.php on line 820

$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);
 ?>

Can anyone please tell me where am I going wrong?

Narendra Rajput
  • 711
  • 9
  • 28
  • Please add the backtrace to the error and tell to which line of code in your question it co-relates - see [How can I get PHP to produce a backtrace upon errors?](http://stackoverflow.com/questions/1159216/how-can-i-get-php-to-produce-a-backtrace-upon-errors) – hakre Dec 19 '11 at 23:11
  • I tried it doing manually and as per the results the error is displayed when the setFileUploadsupport() function is used. – Narendra Rajput Dec 19 '11 at 23:19
  • Check the documentation of that API function, it probably needs more than just the protocol and host in the URI. – hakre Dec 19 '11 at 23:22
  • true, it will almost certainly at least need a trailing `/` – DaveRandom Dec 19 '11 at 23:24

2 Answers2

1

The setfileUploadSupport API you used is not supported by PHP SDK 3.1 in line

 $facebook->setFileUploadSupport("http://" . $_SERVER['SERVER_NAME']);

Change it

 $facebook->setFileUploadSupport(true)
Viren Rajput
  • 5,426
  • 5
  • 30
  • 41
0

You're saving file in the /img/{$me['id'}.png but trying to upload it from other path...

/home/p170r760/public_html/myfbapps/mysupporters/{$me['id']}.png isn't the same as /img/{$me['id'}.png

Juicy Scripter
  • 25,778
  • 6
  • 72
  • 93