发布图像的Facebook相册AS3 API [英] Posting image to Facebook album with AS3 API

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

问题描述

我在与我的画布应用程序到用户的相册发布图像的麻烦。根据Facebook的文档:

  

为了发布照片到用户的相册,你必须有publish_stream权限。随着中理所当然的,你可以通过发出带有照片的内容和一个可选的描述,其中的一个HTTP POST请求到图形API的连接上传照片:

     
      
  1. https://graph.facebook.com/USER_ID/photos - 照片会发布到你的应用程序创建的相册。我们会自动创建相册为您的应用程序,如果它不存在。上传这种方式,所有的照片将被添加到这个相同的专辑。
  2.   
  3. https://graph.facebook.com/ALBUM_ID/photos - 照片会发表由ALBUM_ID psented一个特定的,现有的相册,再$ P $。
  4.   

因此​​,通过一点一点去,如果我上传的图片是这样...

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

...然后我可以指望它把我的形象的命名为我的应用程序的册页,它会创建,如果有必要吗?

并非如此

究竟发生时,这张专辑不存在的是,上传的图片被压入存在的任何其他方便的专辑,这是通常的(和创建)的其他应用程序。这是一个有点疼痛。

到目前为止,我已经尝试了以下内容:

  1. 禁用沙盒模式。我原以为应用程序可能无法创建新的专辑,因为它是在沙盒模式,但禁用沙盒模式没有什么区别,我可以直接创建相册这个功能的。
  2. 检查我的专辑是否存在,如果必要创建它。我可以检查我的专辑创造它,如果它不存在,但我不能再上传图片,因为POST调用 Facebook.api 上传的图像,如果将失败那就不叫作为用户交互的直接结果。

和所以现在我有点难倒。显然,我不能让我的应用程序发布影像到竞争对手专辑的可能性,但目前我能看到的唯一选择将涉及有效地使用户提交自己的形象两次,如果一张专辑已被创建。任何想法?

解决方案

我猜你需要的access_token在PARAMS :)当发布的内容对用户的Facebook,你总是需要这个(并非总是需要获取信息时, )。得到accesstoken的方法如下:)

 公共职能后():无效
{
    VAR _params:对象=新的对象();

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

    Facebook.api(ME /照片,imagePostCallback,_params,URLRequestMethod.POST);
}
 

也确保您要求您的应用程序权限时有正确的权限。

修改

好了,我已经错过了你的编辑了一下那里;)应该可以创建自己的专辑。看看这个PHP的code的图形API。的code也应该能够被解析到AS3

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

EDIT2

好了,我已经做了一些更多的挖掘(挺有意思的,就知道了)。这应该使用图形API时,实际的工作。

  FB.api('/ ME /相册,albumCreateCallback,{名称:这张专辑的名字,留言:这张专辑的说明},URLRequestMethod.POST);
 

当你再调用另一个API调用来上传你的albumCreateCallback图像,它应该工作,并上传你的图片(据我​​已经找到)。

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

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 - 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?

Not so.

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. Disabling sandbox mode. I had thought that the app might be unable to create new albums because it was in sandbox mode, however disabling sandbox mode made no difference and I can create albums directly with it enabled.
  2. Checking for the existence of my album and creating it if necessary. I can check for my album and create it if it does not exist, but I cannot then upload an image because the POST call to Facebook.api to upload the image will fail if it is not called as a direct result of a user interaction.

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?

解决方案

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.

EDIT

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

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);

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).

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

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