我已经动态创建了一个 html 画布图像。我想通过 javascript sdk 将它发布到 facebook 用户的墙上。我正在做的是
我试图将画布转换为 javascript 图像对象并在 fb.ui 方法中提供 finalimage
var temp = canvas.toDataURL("image/png");
var finalimage=temp.replace(/^data:image\/(png|jpg);base64,/, "");
FB.ui(
{
method: 'feed',
name: 'The Facebook SDK for Javascript',
caption: 'Bringing Facebook to the desktop and mobile web',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
link: 'https://developers.facebook.com/docs/reference/javascript/',
picture: finalimage
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
但我收到一个错误
错误消息:图片 URL 格式不正确
谁能帮我怎么做?