使用 AS3 API 将图像发布到 Facebook 相册 [英] Posting image to Facebook album with AS3 API

查看:23
本文介绍了使用 AS3 API 将图像发布到 Facebook 相册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将画布应用程序中的图像发布到用户的相册.根据 Facebook 文档:

I'm having trouble with posting an image from my canvas application to the user's albums. According to the Facebook docs:

要将照片发布到用户的相册,您必须拥有 publish_stream 权限.获得批准后,您可以通过向 Graph API 连接发出包含照片内容和可选描述的 HTTP POST 请求来上传照片:

In order to publish a photo to a user’s album, you must have the publish_stream permission. With that granted, you can upload a photo by issuing an HTTP POST request with the photo content and an optional description to one these to Graph API connections:

  1. https://graph.facebook.com/USER_ID/photos - 照片将是发布到为您的应用创建的相册.如果您的应用尚不存在,我们会自动为您的应用创建相册.以这种方式上传的所有照片都将添加到同一个相册中.
  2. https://graph.facebook.com/ALBUM_ID/photos - 照片将是发布到特定的现有相册,由 ALBUM_ID 表示.
  1. https://graph.facebook.com/USER_ID/photos - The photo will be published to an album created for your app. We automatically create an album for your app if it does not already exist. All photos uploaded this way will then be added to this same album.
  2. https://graph.facebook.com/ALBUM_ID/photos - The photo will be published to a specific, existing photo album, represented by the ALBUM_ID.

所以,从第一点开始,如果我上传这样的图片......

So, going by point one, if I upload an image like this...

Facebook.api("me/photos",imagePostCallback,{message:"",image:myImageBitmap,fileName:''},URLRequestMethod.POST);

...然后我可以期望它把我的图像放在一个以我的应用程序命名的相册中,它会在必要时创建吗?

...then I can expect it to place my image in an album named for my app, which it will create if necessary?

并非如此.

当相册不存在时实际发生的情况是上传的图像被推送到任何其他现有的方便相册中,这些相册通常是为其他应用程序创建的(并由其创建).这有点痛苦.

What actually happens when the album doesn't exist is that the uploaded image is pushed into any other handy albums that exist, which are usually for (and created by) other applications. This is a bit of a pain.

到目前为止,我已经尝试了以下方法:

So far I've tried the following:

  1. 禁用沙盒模式.我原以为该应用可能无法创建新专辑,因为它处于沙盒模式,但是禁用沙盒模式没有任何区别,我可以在启用它的情况下直接创建专辑.
  2. 检查我的相册是否存在并在必要时创建它.我可以检查我的相册并创建它,如果它不存在,但是我不能上传图像,因为如果它没有被称为用户交互的直接结果.

所以现在我有点难住了.显然,我无法将我的应用程序发布图像到竞争对手的相册,但目前我能看到的唯一替代方法是,如果必须创建相册,有效地让用户提交他们的图像两次.有什么想法吗?

And so now I'm a bit stumped. Obviously I can't have the possibility of my app posting images to a competitors album, but at the moment the only alternative I can see will involve effectively making the user submit their image twice if an album has to be created. Any ideas?

推荐答案

我猜你需要在你的参数中使用 access_token :) 在用户的 facebook 上发布内容时,你总是需要这个(在获取信息时并不总是必需的)).获取accesstoken的方法如下所示:)

I'm guessing you need the access_token in your params :) When posting something on a user's facebook, you always need this one (not always necessary when getting information). The way to get the accesstoken is shown below :)

public function post():void
{
    var _params:Object = new Object();

    _params.access_token = Facebook.getSession().accessToken;
    _params.message = "";
    _params.image = myImageBitmap;
    _params.fileName = "";

    Facebook.api("me/photos", imagePostCallback, _params, URLRequestMethod.POST);
}

在请求应用权限时,还要确保您拥有正确的权限.

also make sure that you have the right permissions when asking for permissions with your app.

编辑

好的,所以我有点想念你在那里的编辑;) 应该可以创建你自己的专辑.看看这个图形 api 的 php 代码.代码也应该可以解析为AS3.

Ok, so I've missed your edit a bit there ;) it should be possible to create your own album. Take a look at this php-code for graph api. The code should also be able to be parsed to AS3.

http://developers.facebook.com/blog/post/498/

EDIT2

好的,我已经做了更多的挖掘(似乎很有趣).使用图形 API 时,这实际上应该有效.

ok, i've done some more digging (seemed interesting to know). This should actually work when using graph api.

FB.api('/me/albums', albumCreateCallback, {name: 'name of the album', message: 'description of the album'}, URLRequestMethod.POST);

然后,当您调用另一个 api 调用以在专辑创建回调中上传您的图片时,它应该可以正常工作并上传您的图片(根据我的发现).

When you then call for another api call to upload your image in the albumCreateCallback, it should work and upload your image (according to what i've found).

这篇关于使用 AS3 API 将图像发布到 Facebook 相册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆