使用Facebook的Graph API将照片上传到相册 [英] Upload Photo To Album with Facebook's Graph API
问题描述
我正在努力寻找
根据 http://developers.facebook.com/docs/api#publishing 您需要提供消息参数。但我不太清楚如何构建它。
我读过的旧资源是:
如果有人有更多信息或可以帮助我处理上传照片使用Facebook Graph API的专辑请回复!
以下是使用PHP Facebook Graph API上传照片的各种方法。这些例子假设你已经实例化了$ facebook对象并且有一个有效的会话。
1 - 上传到当前用户的默认应用程序专辑
此示例将照片上传到当前用户的默认应用程序专辑。如果专辑不存在,将会被创建。
$ facebook-> setFileUploadSupport(true);
$ args = array('message'=>'照片说明');
$ args ['image'] ='@'。真实路径($ FILE_PATH);
$ data = $ facebook-> api('/ me / photos','post',$ args);
print_r($ data);
2 - 上传到目标相册
此示例将照片上传到特定的相册。
$ facebook-> setFileUploadSupport(true);
$ args = array('message'=>'照片说明');
$ args ['image'] ='@'。真实路径($ FILE_PATH);
$ data = $ facebook-> api('/'。$ ALBUM_ID。'/ photos','post',$ args);
print_r($ data);
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);
这篇关于使用Facebook的Graph API将照片上传到相册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!