I assume you know how to develop a facebook application
This code below can upload your photo to Profile Pictures album via Facebook application
require_once('fbconfig.php'); try { include_once("facebook.php"); } catch(Exception $c) { echo '';
print_r($o); } $uid = NULL; //facebook user id $facebook = new Facebook(array( 'appId' => $fbconfig['appid'], 'secret' => $fbconfig['secret'], 'cookie' => true )); $session = $facebook->getSession(); //getting username of logged in user $login_url = $facebook->getLoginUrl( array( 'canvas' => 1, 'fbconnect' => 0, 'req_perms' => 'read_stream,publish_stream,photo_upload,user_photos,user_photo_video_tags' ) ); if ($session) { $facebook->setFileUploadSupport(true); // upload feature ON $albums = $facebook->api('/me/albums/'); // getting facebook albums of user foreach ($albums['data'] as $album) { if($album['type'] == 'profile'){ $album_uid = $album['id']; } } $photo_details = array( 'message'=> 'uploaded via application' ); $file = 'photo.jpg'; $photo_details['image'] = '@' . realpath($file); print_r($photo_details); $upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details); echo 'View my photo'; } else { echo ""; exit; }
Leave a comment