如何修复FB Instant Game中的“共享选项”错误

时间:2019-02-15 04:50:18

标签: javascript share facebook-instant-games

此共享代码不适用于桌面共享,但可以在移动共享中正常工作。在台式机上,我遇到了错误。

enter image description here

function getBase64Image(img) {

    var canvas = document.createElement("canvas");
    canvas.width = 614;
    canvas.height = 1079;
    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0);

    var dataURL = canvas.toDataURL("image/png");
    return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}


function fbShare() {


FBInstant.shareAsync(
    {
        intent: 'SHARE',
        image: getBase64Image(document.getElementById('loveimage1')),
        text: 'What type of lover are you? Find Out. Share. Win.',
        data: {
                myReplayData: '...'
            }
    }).then( function()
    {
    console.log("sharing is done");
    })
    .catch( function(err)
    {
    console.log('failed to share: ' + err.code + " :: " + err.message);
    });
};

0 个答案:

没有答案