www.webdeveloper.com
Results 1 to 4 of 4

Thread: [Help] Upload Photos to Facebook PHP SDK

  1. #1
    Join Date
    Oct 2013
    Posts
    3

    [Help] Upload Photos to Facebook PHP SDK

    Hi, I want to make a php script upload photos to facebook, something like:

    Code:
    http://newfbcovers.com/wp-content/themes/fbcovers/fb/?i=http://newfbcovers.com/wp-content/uploads/Successful-marriage1.png
    please help me ! thanks for your help !

  2. #2
    Join Date
    Oct 2013
    Posts
    3

  3. #3
    Join Date
    Sep 2013
    Posts
    221
    For uploading a photo to the current User's profile you have to use the Graph API and Facebook SDK for PHP.
    Try out with the below example:
    $appId = 'YourAppId';
    $secret = 'YourSecret';

    $facebook = new Facebook(array(
    'appId' => $appId,
    'secret' => $secret,
    'cookie' => true,
    ));

    $session = $facebook->getSession();

    $login_url = $facebook->getLoginUrl(
    array(
    'req_perms' => 'read_stream,publish_stream,photo_upload,user_photos,user_photo_video_tags'
    )
    );

    if ($session) {
    $facebook->setFileUploadSupport(true);

    $albums = $facebook->api('/me/albums');
    foreach ($albums['data'] as $album) {
    if($album['type'] == 'profile'){
    $album_uid = $album['id'];
    }
    }

    $photo_details = array(
    'message'=> 'Photo message'
    );
    $file = 'photo.jpg';
    $photo_details['image'] = '@' . realpath($file);

    $upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);

    echo '<a href="http://www.facebook.com/photo.php?fbid='.$upload_photo['id'].'" target="_blank">View my photo</a>';
    }
    else {
    echo '<a href="'.$login_url.'">Login</a>';
    }

    Hope this helps.
    strad solutionswww.stradsolutions.com

  4. #4
    Join Date
    Oct 2013
    Posts
    3
    i try this but no photo upload to facebook

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles