Here are some ways to upload photos using the PHP Facebook Graph API. The examples assume that you created an instance of the $ facebook object and have a live session.
1 - Download the default application album of the current user
In this example, you upload the photo to your default application album of the current user. If the album does not exist yet, 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
In this example, 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);
Brody Robertson Jun 09 2018-10-06 14:39
source share