Getting Fatal Error Uncaught CurlException: 26: Could not open file

I am trying to create a dynamic image of my friends using the PHP GD Library and I need to upload this to my friends profile, but I continue to receive the error message Fatal error: Uncaught CurlException: 26: Could not open file "" thrown in / home / p 170r760 / 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 someone tell me where I will be wrong?

0
source share
2 answers

The setfileUploadSupport API you are using is not supported by the PHP SDK 3.1 in line

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

Change it

  $facebook->setFileUploadSupport(true) 
+1
source

You save the file in /img/{$me['id'}.png , but you try to download it from another path ...

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

0
source

Source: https://habr.com/ru/post/969493/


All Articles