简体   繁体   中英

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.

I also tried facebook debug, but no luck

Page link: http://www.anothercrush.com/polling-detail/second-post

Steps:

  1. Fill the 3 fields and submit

  2. Now you can able to see the facebookshare button above the image, just click it

  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

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.

Another way to share and call this method shareOnFacebookUser() on your click

    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 {
                }
            });
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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