facebook js api - HTML5 canvas upload as a photo

99封情书 提交于 2019-12-13 06:00:39

问题


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

回答1:


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

You can have PNG also.

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.

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.



来源:https://stackoverflow.com/questions/11739908/facebook-js-api-html5-canvas-upload-as-a-photo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!