【发布时间】:2015-10-22 04:48:08
【问题描述】:
我的脚本:
<div id="fb-root"></div>
<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#xfbml=1&version=v2.3";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
元标记
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="..
all over Malaysia. Visit us now for Home Tuition and More!"/>
<meta name="keywords" content="content goes here"/>
<title>Tutor Registration: Gloopal- Home tuition and More!</title>
<meta property="og:title" content="Malaysia's Best Private Tutoring Website" />
<meta property="og:image" content="https://[sample.com]/img/fb.png" />
<meta property="og:image:secure_url" content="https://[sample.com]/img/fb.png" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="400" />
<meta property="og:image:height" content="300" />
<meta property="og:description" content="Visit [sample.com] today for the most reliable, brilliant and honest tutors from all over Malaysia! We've got you covered, for the widest ever range of subjects. We charge ZERO fees/commission for students and tutors, for all tutoring arrangements- we're one of a kind indeed!" />
<!--open graphs ends-->
jquery 附加的 html
<div class='fb-share-button' data-href='https://gloopal.com/index.php' data-layout='button'></div>
当我在 [https://sample.com] 上尝试上述操作时,在浏览器上刷新几轮后它运行良好。
接下来,我尝试分享更具体的帖子,而不是分享整个网站。因此,在每个共享按钮上都引用了一个带有 ID 的页面。但是它只是忽略了它,只显示了一般网站。我不明白为什么我没有得到带有 ID 的特定页面并显示该页面的内容。
<div class='fb-share-button' data-href='https://gloopal.com/search2.php?TID="+ tid +"' data-layout='button'></div>
现在,我尝试分享网站,因为我已经创建了一个子域来进行改造工作。在此域中,按钮的基本共享不显示附加的图像和描述,更不用说通过 ID 共享了。
当我在 facebook debug 中调试时,它显示了这个错误:
解析输入 URL 时出错,没有数据被缓存,或者没有数据被抓取。
然后我读了几个问题就学到了几个小技巧:为了在facebook上抓取内容,必须为图片设置with和height。此外,facebook 不会在第一次加载时显示图像,因此必须保持刷新。尽管我在文件中更改了以前缓存的内容,但 Facebook 也不会删除它们。所以我需要在放置我的 URL 一次或两次后重新刷新 facebook 调试。不仅如此,我还了解到即使 HTTPS 也会导致问题,所以我什至尝试用 http 替换它,并在图像元标记上添加了 secure_url。
尽管我做了所有尝试,我仍然无法在 facebook 上分享图片和内容。如果有人知道我缺少什么,也请帮我一个忙,让我知道如何通过 ID 分享帖子,这意味着不同的图片,每个 ID 的内容。
提前感谢您的帮助。
【问题讨论】:
标签: javascript php facebook facebook-graph-api