facebook js api - HTML5 canvas上传为照片 [英] facebook js api - HTML5 canvas upload as a photo

查看:139
本文介绍了facebook js api - HTML5 canvas上传为照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将HTML5画布转换为某种图像格式,以便可以通过js api上传到Facebook用户应用专辑,

Is there a way to convert an HTML5 canvas to a some sort of an image format so that it can be uploaded to facebook users application album though the js api,

我目前已成功将图像链接上传到具有以下功能的相册:

I'm currently successfully uploading an image link to an album with the following function:

FB.api('/me/photos', 'post', { message:'the message', url:imgURL});


推荐答案

是的,有办法将HTML5 Canvas转换为图片。在Canvas JS元素上执行以下javascript函数将执行以下操作:

Yes, there is way to convert HTML5 Canvas to an image. Following javascript function on the Canvas JS element will do this:

toDataURL('image/jpeg', 1.0);

您也可以拥有PNG。

此函数将生成画布图像的Base64表示。我不确定您是否可以直接向Facebook API提供Base64字符串。

This function will generate a Base64 representation of the canvas image. I am not sure if you can directly give a Base64 string to the Facebook API.

如果可以,那就太棒了,否则你需要暂时将它保存在服务器上并将该URL提供给FB API。

If you can, then it will be great, otherwise you need to save it temporarily on the server and give that URL to the FB API.

这篇关于facebook js api - HTML5 canvas上传为照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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