2016-03-01 120 views
-3

我试图与我的网站上的图像共享一篇文章,但只有图像没有得到共享,我检查了og:图像在视图源上它来自视图源,但它不是来在分享框和共享文章上。Facebook的图像共享不起作用

我也试过Facebook的调试,但没有运气

页面链接: http://www.anothercrush.com/polling-detail/second-post

步骤:

  1. 填写的3个字段,并提交

  2. 现在,您可以能看图片上方的facebookshare按钮,只需点击它

  3. 现在您将在共享框上发布问题(空白框而不是图像)。

请找到解决

+2

* “步骤......” * - Errrr。没有。你标记为php,所以发布你的代码。访问网站包含呈现的HTML/PHP,而不是源代码。 –

+0

嗨 这是我用于共享的代码 Raja

+0

有没有解决方法? – Raja

回答

1
This code works for me you can try 
    <meta property="og:url" content="http://domain.com"/> 
    <meta property="og:title" content="PageTitle"/> 
    <meta property="og:description" content=" Description"/> 
    <meta property="og:image" content="image path"/> 
    <meta property="og:site_name" content="title" /> 
    <meta property="fb:app_id" content="correct facebook app id"/> 

Facebook的控制台This is usefull to check your link Facebook console

我检查页面查看源代码的meta标签,但我没有发现OG:图像属性,如果你只传递呢? u =然后其他的将从og标签中获取,所以请按照这个或者传递你想要的所有参数,如果你没有传递其他参数,它会在页面中搜索任何第一个找到的东西,比如你现在工作的图像。

另一种方式来对您的点击共享和调用此方法shareOnFacebookUser()

var appId='FACEBOOK_ID'; 
     window.fbAsyncInit = function() { 
      // init the FB JS SDK 
      FB.init({ 
       appId: appId, // App ID from the app dashboard  
       status: true, // Check Facebook Login status 
       xfbml: true // Look for social plugins on the page 
      });  
     }; 

     // Load the SDK asynchronously 
     (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 = "https://connect.facebook.net/en_US/all.js"; 
      fjs.parentNode.insertBefore(js, fjs); 
     }(document, 'script', 'facebook-jssdk')); 

      function shareOnFacebookUser() { 
      var img = $("#image").val(); 
      var link = $("#link").val(); 
      var title = $("#name").val(); 
      var desc = $("#desc").val(); 
      FB.ui({ 
       method: 'feed', 
       link: link, 
       name: title, 
       picture: img, 
       description:desc 

      }, function (response) { 
       if (response && response.post_id) { 
       } 
       else { 
       } 
      }); 
     } 
+0

嗨SRK, 感谢您的回复,我已经有了这段代码,我的问题是图片在共享帖子后被拉到了Feed页面上,但是当我点击分享按钮时,图片没有被拉到Facebook分享框中。共享框只显示标题和说明,如果我分享后的图像来源饲料,我只是想显示在共享框 – Raja

+0

你能分享的JavaScript代码共享按钮来检查 –

+0

前2次,当我点击分享按钮图像没有被拉到共享框,但如果我点击共享按钮第三次它被拉,我只想知道为什么它被拉到前2次,如何修复它。 – Raja