Facebook和Whatsapp共享按钮

时间:2017-10-21 08:52:55

标签: php facebook facebook-graph-api facebook-javascript-sdk facebook-php-sdk

我有一个PHP页面向用户显示图像,我希望它们通过Facebook或WhatsApp共享, 这里是头部的代码:

<meta name="description" content="<?php echo $Rowdati['metadescrizione'];?>">
<meta name="keywords" content="<?php echo $Rowdati['keywordsapp'];?>">
<meta property="og:image" content="<?php echo $urlimmagineuser; ?>">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="400">
<meta property="og:image:height" content="400">
<meta property="og:title" content="<?php echo $Rowdati['titolo_fb_share'];?>">
<meta property="og:description " content="<?php echo $Rowdati['descr_fb_share'];?>">

此处是用于在网页上分享和显示图像的代码:

<?php echo "<a href='". $url ."' download='image-ready'>
    <img id='immaginelaborata' class='img-responsive' src='". $url ."' />
    </a>";
?>

这里是分享按钮:

<div class="col-sm-4" data-href="<?php echo $actual_link;?>" data-layout="button" data-size="large" data-mobile-iframe="true">
    <button class="btn col-xs-12 scroll_effect shadow-top-down">
        <a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $actual_link;?>;src=sdkpreparse">
        <i class="fa fa-facebook-square" aria-hidden="true"></i><br>share on FB</a>
    </button>
</div>
<div class="col-sm-4">
    <button class="btn col-xs-12 scroll_effect shadow-top-down">
        <?php 
            $actual_link = (isset($_SERVER['HTTPS']) ? "https" : "http") .         
            "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
        ?>
        <a href="whatsapp://send?text=<?php echo $Rowdati['testo_whatsapp'] . "http://mydomain.it";?>" data-action="share/whatsapp/share">
            <i class="fa fa-whatsapp" aria-hidden="true" ></i><br>share on Whatsapp<br>
        </a>
    </button>
</div>

该页面工作正常,但在Facebook或WhatsApp上分享时,它不会返回图像预览... 检查并重新检查代码后,我无法弄清楚为什么。

0 个答案:

没有答案