3

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 の形式が正しくありません

どうすればそれを行うことができますか?

4

1 に答える 1