2017-07-28 10 views
0

私はfacebookタブアプリを持っています。その中に共有ボタンがありますfacebook share not added画像

<p class="share-btn" id="button">share this</p> 

<script> 

    (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> 
    window.fbAsyncInit = function() { 
     FB.init({ 
      appId: 'app id', 
      cookie: true, 
      xfbml: true, 
      version: 'v2.8' 
     }); 

     window.facebookShare = function (callback) { 
      var id = @Model.Id; 

      var options = ({ 
       method: 'share', 
       href: 'https://www.facebook.com/my app url here&app_data=' + id 
      }), 
       status = ''; 

      FB.ui(options, function (response) { 
       console.log(response); 
       if (response && !response.error_code) { 
        status = 'success'; 
        $.event.trigger('fb-share.success'); 

       } else { 
        status = 'error'; 
        $.event.trigger('fb-share.error'); 
       } 

       if (callback && typeof callback === "function") { 
        callback.call(this, status); 
       } else { 
        return response; 
       } 
      }); 
     } 

    }; 



    $('#button').on('click', function (e) { 
     e.preventDefault(); 

     facebookShare(function (response) { 
      // simple function callback 
      //console.log(response); 
     }); 
    }); 

    // custom jQuery events 
    $(document) 
     .on('fb-share.success', function (e) { 
      window.location.href = "/Quiz/Finished"; 
     }) 
     .on('fb-share.error', function (e) { 
      //alert("fail"); 
     }); 
</script> 

この共有リンクはOKですが、サムネイルを追加していません。シェアは、このなります

enter image description here

しかし、私のレイアウトで、私はこれらを持っている:

<meta property="og:url" content="http://www.your-domain.com/your-page.html" /> 
<meta property="og:type" content="website" /> 
<meta property="og:title" content="Your Website Title" /> 
<meta property="og:description" content="Your description" /> 
<meta property="og:image" content="https://www.codeproject.com/KB/aspnet/AspnetPaths/SelectImage.png" /> 

私はそれをどのように行うことができますか?オプションを使用して画像を渡す機会はありますか?

+0

_your_ URLのメタタグに効果があるようにするには、_your_ URLを共有する必要があります。必要に応じてそこから人間のユーザーをページタブにリダイレクトします。 – CBroe

答えて

-1

あなたのURL

https://developers.facebook.com/tools/debug/

それはあなたに正確なエラーを教えてくれますし、このツールを試すことができます。

おはようございます!

+0

ありがとうございますが、「警告 FacebookのURLをクロールできません。」 – gsiradze

+0

あなたが試しているURLはどれですか? –