我可以通过将数据发布到
I can create an album using facebook graph api by posting data to
graph.facebook/ALBUM_ID/albums它返回一个id,而不是相册ID。
it returns an id, which is not the album id.
我以两种方式确认了
我需要知道真实的相册ID,以便我可以上传图像新创建的相册。
I need to know the real album id so that i can upload images to newly created album.
推荐答案新的php-sdk正常工作,我刚刚测试过,我的意见:
The new php-sdk is working just fine, I've just tested it and here are my comments:
1.确保您具有适用于 publish_stream 的正确扩展权限.facebook /文档/参考/ API /专辑/ rel =nofollow noreferrer>相册创作和照片上传。
1.Make sure you have the right extended permission which is publish_stream for both Album creation and Photo upload.
2.使用以下代码创建相册后,您将收到相册ID:
2.After creating the Album using the below code, you'll receive the Album ID:
$post_data = array( 'name'=>"My Test Album", 'description'=>"My Test Album Desc" ); $data['album'] = $this->facebook->api("/me/albums", 'post', $post_data);PS:我确认此ID不是您在浏览Facebook时看到的ID
P.S: I confirm this ID is NOT the ID you see when browsing Facebook
3.现在,我们需要使用您获得的专辑参考ID上传图像:
3.Now we need to upload the image with the Album "reference" ID you got:
$file = FCPATH . "assets/img/small1.jpg"; $post_data = array( "message" => "My photo caption", "source" => '@' . realpath($file) ); $album_id = "473425002142"; $data['photo'] = $this->facebook->api("/$album_id/photos", 'post', $post_data);PS:常量 FCPATH 是一个Codeigniter常数,你可以 $ _ SERVER ['DOCUMENT_ROOT'] 或任何你喜欢的方法。
P.S: the Constant FCPATH is a Codeigniter constant, you can you $_SERVER['DOCUMENT_ROOT'] or whatever method you are comfortable with.
结果:
And the result:
更多推荐
将图像上传到特定的Facebook相册
发布评论