Advertisement
Frank84

Upload image to facebook

Jun 11th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. function base64_to_jpeg( $base64_string, $output_file ) {
  2.   $ifp = fopen( $output_file, "wb" );
  3.   fwrite( $ifp, base64_decode( $base64_string) );
  4.   fclose( $ifp );
  5.   return( $output_file );
  6. }
  7. $facebook->setFileUploadSupport(true);
  8. $image = base64_to_jpeg( $your_base64_string, 'tmp.jpg' );
  9. $args = array('message' => 'Some message');
  10. $args['image'] = '@' . realpath( $image );
  11. $data = $facebook->api('/your_user_id/photos', 'post', $args);
  12. unlink($image);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement