Open Graph元标记无法访问,Facebook页面预览显示" 422"?

时间:2015-11-07 23:28:06

标签: ruby-on-rails facebook facebook-graph-api meta-tags

我无法访问Facebook的开放图表标签。当我尝试共享页面时,网站链接正常,但og属性不会显示,标题只显示为" 422"。我不确定这意味着什么。

当我运行facebook调试器https://developers.facebook.com/tools/debug/og/object/时,我收到以下错误,这不是非常有用:

Error parsing input URL, no data was cached, or no data was scraped.

使用调试工具中的echo功能,我得到的是:

Document returned no data

元标记似乎在我的文档中正确设置:

<!DOCTYPE html>
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="robots" content="noarchive,noodp,noydir" />
  <meta name="referrer" content="always" />
  <meta property="fb:app_id" content="375576830972731" />
  <meta property="og:site_name" content="Site Name" />
  <meta property="og:title" content="Title of content" />
  <meta property="og:url" content="https://website.domain.com/123456" />
  <meta property="og:image" content="http://s3-us-west-1.amazonaws.com/domain/media/images/001/original/001" />
  <meta property="og:description" content="Description of content" />
  <meta property="og:type" content="article" />
</head>

我确保允许robots.txt中的Facebook抓取工具:

User-agent: Facebot
Allow: /

User-agent: facebookexternalhit/1.1
Allow: /

我错过了什么?

1 个答案:

答案 0 :(得分:0)

这里的问题是protect_from_forgery中的application.rb方法。我添加了一个例外,Facebot现在可以看到该页面了。

class StoriesController < ApplicationController    
  protect_from_forgery except: :show