2014-10-02 55 views
1

我的腳本代碼:分享圖片給我的錯誤

<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '878892922141778', 
     xfbml  : true, 
     version : 'v2.1' 
    }); 
    }; 

    (function(d, s, id){ 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/sdk.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 




</script> 

<script type="text/javascript"> 
    function publishOnFacebook() { 
    FB.ui(
    { 
    method: 'feed', 
    name: 'Facebook Dialogs', 
    link: 'https://apps.facebook.com/878892922141778', 

    caption: 'Reference Documentation', 
    description: 'Dialogs provide a simple, consistent interface for applications to interface with users.' 
    }, 
    function(response) { 
    if (response && response.post_id) { 
     alert('Post was published.'); 
    } else { 
     alert('Post was not published.'); 
    } 
    } 
); 
} 
</script> 

而且按鈕的份額爲:

<a hre="#" onclick="publishOnFacebook();" data-share="fb"><span class="fb-icon"></span></a> 

但是,當我在分享按鈕點擊,它給我的錯誤:

API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application. 

什麼可以是錯誤?

我的應用程序細節:

enter image description here

當我添加:

<a href="javascript:void(o);" 
          onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href),'facebook-share-dialog', 'width=626,height=436'); 
           return false;"> 
       SHARE 

      </a> 

這股整頁。但我只想分享特定的圖像。

請幫幫我。

回答

1

如果你想分享的圖片還那麼你可以使用該代碼在FB.ui方法

picture: 'https://apps.facebook.com/test.png'  // your image path 

我希望這可以幫助你。