Home > Article > Backend Development > How to Upload Photos to Facebook Albums Using the Graph API?
Uploading images to Facebook albums using their Graph API requires a specific "message" argument. The documentation around its construction can be confusing.
1. Default Application Album
To upload a photo to the default album of the current user, utilize the following syntax:
$facebook->setFileUploadSupport(true); $args = ['message' => 'Photo Caption', 'image' => '@' . realpath($FILE_PATH)]; $data = $facebook->api('/me/photos', 'post', $args);
2. Target Album
For uploading to a specific album, follow this format:
$facebook->setFileUploadSupport(true); $args = ['message' => 'Photo Caption', 'image' => '@' . realpath($FILE_PATH)]; $data = $facebook->api('/' . $ALBUM_ID . '/photos', 'post', $args);
The above is the detailed content of How to Upload Photos to Facebook Albums Using the Graph API?. For more information, please follow other related articles on the PHP Chinese website!