Posted By

kwanhon on 07/12/10


Tagged

upload photo


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

eval


Facebook Upload Photo API


 / Published in: PHP
 

  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  

You need to login to post a comment.