Facebook使用Iframe分享JavaScript SDK v3.x

时间:2018-08-14 17:59:33

标签: javascript facebook sdk facebook-javascript-sdk facebook-share

使用供稿或共享进行Facebook共享可以成功回叫,并且可以判断用户是否共享,但是在使用iframe时,它始终表示用户取消了对话框{error_code: 4201, error_message: "User+canceled+the+Dialog+flow"},无法判断用户是否共享了,但未使用iframe的相同功能正常工作

function sharfeToFacebook() {
        var deferred = $q.defer();
        var options = {
            method: 'share',
            mobile_iframe: true,
            href: photoUrl,
        };
        FB.ui(options, function(response) {
            console.log('FB share dialog started with response: ', response);
            if (response && !response.error_code) {
                // fb does returns an emtpy object on success, undefined when fail or canceled
                deferred.resolve(response);
            } else {
                deferred.reject(response);
            }
        });
    }
    return deferred.promise;

0 个答案:

没有答案