【问题标题】:Facebook not getting meta tag and not able to scrape URLFacebook 没有获取元标记,也无法抓取 URL
【发布时间】:2014-08-27 12:53:42
【问题描述】:

我正在使用 addthis 在社交网站上进行分享。我正在尝试在 FB 上分享标题、描述等。它正在工作,但没有得到我的标题和描述。

我正在使用 Open Graph Debugger 工具,它说

“网站”类型的 URL“XXXXX”处的对象无效,因为未提供“字符串”类型的必需属性“og:title”。

当我点击Scraped URL See exactly what our scraper sees for your URL 它没有显示。 那么问题出在哪里?

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:og="http://ogp.me/ns#"
  xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta property="og:title" content="APPOITMENT" />
<meta property="og:type" content="article" />
 <meta property="og:url" content="http://xxxxxxxx/client/appointment/index" />
 <meta property="og:site_name" content="CBD"/>
  <meta property="og:description" content="Workday, a provider of cloud-" />

我做了一些调试。我使用 codeigniter 框架,并使用 .htaccess 文件进行重定向。当我在核心 php 文件中使用相同的代码时,它正在工作。但在 codeigniter 中它不起作用。

.htaccss:

 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule .* index.php/$0 [PT,L]

EDIT:

似乎 CI 使用像控制器/函数/这样的 URL。所以我认为这是 FB 无法抓取页面的原因。那么我需要创建包含元标记的单个 php 文件吗?

【问题讨论】:

  • 当您点击“查看我们的抓取工具为您的 URL 看到的确切内容”看不到任何内容 - 但如果您查看该页面的来源,您会看到那里有内容(只是没有视觉内容)-但确实缺少og:tags
  • @Lix:是的,但是该页面包含可视数据以及元标记。如果我在单个 php 文件中运行相同的代码,那么它可以工作,但在 CI 中它不工作。可能是因为 .htaccss 文件。
  • 我没有使用 codeigniter 的经验,所以我无法真正帮助你。

标签: codeigniter facebook-graph-api addthis


【解决方案1】:

尝试调试您的根 URL。 https://developers.facebook.com/tools/debug/

这也将迫使 Facebook 更新您的元详细信息。

【讨论】:

  • 我用那个,上面写着:The 'og:type' property is required, but not present。奇怪的是它在核心 php 文件中工作,但不在框架中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 2019-10-09
相关资源
最近更新 更多