Here are some various ways to upload photos using the
PHP Facebook Graph API. The examples assume you've instantiated the $facebook object and have a valid session.
1 - Upload to Default Application Album of Current User
This example will upload the photo to your default application album of the current user. If the album does not yet exist it will be created.
$facebook->setFileUploadSupport(true);
$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);
$data = $facebook->api('/me/photos', 'post', $args);
print_r($data);
2 - Upload to Target Album
This example will upload the photo to a specific album.
$facebook->setFileUploadSupport(true);
$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);
$data = $facebook->api('/'. $ALBUM_ID . '/photos', 'post', $args);
print_r($data);
No comments:
Post a Comment