将图像上传到特定的Facebook相册

编程入门 行业动态 更新时间:2024-10-28 14:30:49
本文介绍了将图像上传到特定的Facebook相册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以通过将数据发布到

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收到
  • ,并发布 graph.facebook/ {ALBUM_ID_I_RECIEVED} /照片,但照片从未公开到新创建的专辑,而是发布到默认应用程序专辑。
  • by going to that album, aid is different than what id i received
  • and by posting graph.facebook/{ALBUM_ID_I_RECIEVED}/photos, but the photo is never published to newly created album instead it is published to a default application album.
  • 我需要知道真实的相册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相册

    本文发布于:2023-10-05 12:22:11,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1467366.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:图像   相册   Facebook

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!