简体   繁体   English

Facebook 图像共享不起作用

[英]Facebook image share is not working

I have tried to share a post with image from my website, but only image is not getting shared, I checked the og:image on view source it comes on the view source, but it's not coming on the share box and shared post.我试图从我的网站上分享一个带有图片的帖子,但只有图片没有被共享,我检查了查看源上的 og:image 它出现在视图源上,但它没有出现在共享框和共享帖子上。

I also tried facebook debug, but no luck我也试过 facebook 调试,但没有运气

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

Steps:脚步:

  1. Fill the 3 fields and submit填写3个字段并提交

  2. Now you can able to see the facebookshare button above the image, just click it现在您可以看到图片上方的 facebookshare 按钮,只需单击它

  3. now you'll the issue(blank box instead of image) on the share box.现在您将在共享框上显示问题(空白框而不是图像)。

Please find the solution请找出解决办法

   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 console This is usefull to check your link Facebook console Facebook 控制台这对于检查您的链接 Facebook 控制台很有用

i checked your meta tags in page view source but i did not found the og:image property and if you pass only this ?u= then other will fetch from og tags so please follow this or pass all the parameter you want, if you do not pass other parameter, it will search in page whatever found first, like your image working now.我在页面视图源代码中检查了你的元标记,但我没有找到 og:image 属性,如果你只传递这个不传递其他参数,它将在页面中搜索首先找到的内容,就像您的图像现在工作一样。

Another way to share and call this method shareOnFacebookUser() on your click在您点击时共享和调用此方法 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 {
                }
            });
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM