Facebook Upload Photo API


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $token = $session['access_token'];
  2.  
  3. //upload photo
  4. $file= 'photo.jpg';
  5. $args = array(
  6. 'message' => 'Photo from application',
  7. );
  8. $args[basename($file)] = '@' . realpath($file);
  9.  
  10. $ch = curl_init();
  11. $url = 'https://graph.facebook.com/me/photos?access_token='.$token;
  12. curl_setopt($ch, CURLOPT_URL, $url);
  13. curl_setopt($ch, CURLOPT_HEADER, false);
  14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  15. curl_setopt($ch, CURLOPT_POST, true);
  16. curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
  17. $data = curl_exec($ch);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.