简体   繁体   中英

Facebook api sdk 4.0 php 5.5 - Fatal error: Uncaught exception 'Facebook\FacebookSDKException' - can't upload photo to facebook

I am trying to implement an app that allows the user to choose a photo from their computer to upload onto facebook via my app. For the full code, please refer to: Facebook API sdk 4.0 - post a photo onto facebook

My code seems to be right - user uploads a photo via the form onto the server and then an API request is sent to POST the photo onto facebook, however I have this error:

   Uncaught exception 'Facebook\FacebookSDKException' with message 'couldn't open file   
   "uploads/10419411_10152352973347745_2810638062953115781_n.jpg"' in      
   C:\xampp\htdocs\app\Facebook\HttpClients\FacebookCurlHttpClient.php:142 Stack trace: #0
   C:\xampp\htdocs\app\Facebook\FacebookRequest.php(248): Facebook\HttpClients\FacebookCurlHttpClient-
   >send('https://graph.f...', 'POST', Array) #1 C:\xampp\htdocs\app\index.php(180): Facebook\FacebookRequest-
   >execute() #2 {main} thrown in C:\xampp\htdocs\app\Facebook\HttpClients\FacebookCurlHttpClient.php on line 142

CURL is enabled. And my folder and file's permissions are readable. I really have no idea what this error means. I looked at line 142 in FacebookCurlHttpClient, and it's to do with curlErrorCode. Does anyone know what this means and how to fix?

Check the permissions of your upload folder on the server and make sure your script can read the files in there. Try chmod 755 * on the folder to enable read permissions for all files and see if that fixes your issue.

If that doesn't work, try change the permission of the file after you upload it to the server using PHP, but before you upload it to Facebook.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM