如何允许 Facebook 访问受保护的内容
我在受密码保护的页面上使用 Facebook 评论。我最近发现,当创建新帖子时,我收到错误“facebook comments {page} 无法访问”,并且当我使用 Facebook 的调试工具进行调试时,找不到 ID。 FB 命名空间、元标记和 js 均已正确插入,并且在所有非受保护页面上都能正常工作。
当我禁用密码保护并刷新页面时,一切正常,并且在正确加载后,当我重新启用密码保护时,一切似乎都很好。
所以我猜 Facebook 需要能够第一次访问该页面才能将其设置在数据库中?
有什么办法可以让 Facebook 最初访问该页面。例如,在我的验证函数中,我可以添加:
if( can_user_view_content() || is_request_from_facebook() ){
//echo content and comments
Facebook 是否发送我可以使用的用户代理字符串,或者是否有比测试用户代理更好的方法?
谢谢
I am using Facebook comments on password protected pages. I have recently found that when a new post is created I get the error 'facebook comments {page} is unreachable' and when I debug using Facebook's debug tool no ID is found. FB Namespace, meta tag and js are all inserted correctly and work fine on all non protected pages.
When I disable the password protection and refresh the page everything works fine and after being loaded correctly that once it seems to be fine when I re enable the password protection also.
So I guess Facebook needs to be able to access the page the first time to set it up in it's database?
Is there a way I can allow Facebook to access the page initially. For example in my verification function I could add:
if( can_user_view_content() || is_request_from_facebook() ){
//echo content and comments
Does Facebook send a useragent string I could use or is there a better way than testing for user agent?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Facebook 的机器人通常使用用户代理标头
FacebookExternalHit/1.1
或FacebookExternalHit/1.0
进行操作(但版本号可能会在某个时刻增加)如果您通常将内容设置为登录用户但需要爬虫到达您的页面,请注意,只要返回开放图元标记,您就不需要将完整内容返回给爬虫
(即在登录页面的常规内容上也放置您使用的相同标签)
Facebook's bot usually operates with the user agent header
FacebookExternalHit/1.1
orFacebookExternalHit/1.0
(but the version number could increment at some point)If you normally gate your content to logged in users but need the crawler to reach your page, note that you don't need to return the full content to the crawler provided that the open graph meta tags are returned to it
(i.e put the same tags you'd use on the regular content for the login page also)