Read Random Post

Monday, October 31, 2011

Upload image to facebook album using fb PHP SDK

function uploadPhotos($imagePath, $imageName, $countdowntype) {
        try {
                
        //At the time of writing it is necessary to enable upload support in the Facebook SDK, you do this with the line:
        $facebook = $_SESSION['facebook'];
        $facebook->setFileUploadSupport('http://localhost/WCSERVER/index.php');
        $response = $facebook->api(
          '/me/photos/',
          'post',
          array(
            'message' => '‎4 years, 6 months, 11 days, 18 hours, 56 minutes, 3 seconds until our '.$countdowntype,
                'name' => 'Wedding Countdown Photos',
            'source' => '@'.$imagePath.$imageName // @-sign must be the first character
          )
        );
        } catch (FacebookApiException $e) {
        error_log('Could not post image to Facebook.');
        }
}

0 comments: