6

Download a photo to an album with the graphic API of Facebook

 2 years ago
source link: https://www.codesd.com/item/download-a-photo-to-an-album-with-the-graphic-api-of-facebook.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Download a photo to an album with the graphic API of Facebook

advertisements

I'm trying to familiarize myself with Facebook's new Graph API and so far I can fetch and write some data pretty easily.

Something I'm struggling to find decent documentation on is uploading images to an album.

According to http://developers.facebook.com/docs/api#publishing you need to supply the message argument. But I'm not quite sure how to construct it.

Older resources I've read are:

If someone has more information or could help me tackle uploading photos to an album using Facebook Graph API please reply!


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);


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK