简体   繁体   English

Facebook使用GWT打开图表

[英]Facebook Open graph with GWT

We are developing a page with GWT that has a list view and selecting an item it opens a detail with ajax style, there is no refresh in the page and a new view is shown in the client. 我们正在开发一个包含GWT的页面,该页面具有列表视图并选择一个项目,它打开一个具有ajax样式的细节,页面中没有刷新,并且客户端中显示了新视图。 When that detail is shown( or accessed directly by its url), the meta tags for the Open Graph are set in the header. 当显示该详细信息(或直接通过其URL访问)时,将在标题中设置Open Graph的元标记。 That detail is our Open Graph object. 这个细节是我们的Open Graph对象。

The problem is that setting meta tags by code (even at the beginning of the onModuleLoad method) doesn't work because Facebook doesn't detect them when a user performs an action and Facebook thinks that the page is not an Open Graph one. 问题是通过代码设置元标记(即使在onModuleLoad方法的开头)也不起作用,因为Facebook在用户执行操作时没有检测到它们,Facebook认为该页面不是Open Graph。 We suppose FB reads the page directly without executing any javascript. 我们假设FB直接读取页面而不执行任何javascript。

Any ideas or workaround with that? 任何想法或解决方法?

Thanks in advance. 提前致谢。

Some more recent information to refer to: 最近提到的一些信息:

Put the OpenGraph tags in your server side HTML rendering, like detailed here: http://www.gwtproject.org/articles/dynamic_host_page.html#servlet 将OpenGraph标记放在服务器端HTML呈现中,如下所示: http//www.gwtproject.org/articles/dynamic_host_page.html#servlet

Since Google considers AJAX crawling deprecated, they recommend using the HTML rendering on the server side as well: https://webmasters.googleblog.com/2015/10/deprecating-our-ajax-crawling-scheme.html 由于Google认为不推荐使用AJAX抓取功能,因此他们建议您在服务器端使用HTML呈现: https//webmasters.googleblog.com/2015/10/deprecating-our-ajax-crawling-scheme.html

You'll need to this server-side, with a handler that takes an object id from the query string or path, and does two things: 你需要这个服务器端,使用从查询字符串或路径获取对象id的处理程序,并做两件事:

  1. write out the correct tags for facebook. 为facebook写出正确的标签。
  2. 'deep-link' into your GWT app to show the detail view for the object. “深入链接”到您的GWT应用程序中以显示对象的详细视图。

So for URLs like: 对于以下网址:

http://myapp.com/og/?type=movie&id=1234
http://myapp.com/og/?type=film&id=6789

The HTML output should have all the tags for the object specified, and it should launch your GWT app with a 'bookmark' or some other info it needs to navigate to the detail view. HTML输出应该包含指定对象的所有标记,它应该使用“书签”或导航到详细视图所需的其他信息启动GWT应用程序。

Each object needs its own permanent, distinct URL. 每个对象都需要自己永久的,不同的URL。 So when you pass it to the facebook API, facebook can 'crawl' it, and they can publish it as a link in news feed stories etc. (so machine readable, and shows the relevant content for non-machines!) 因此,当您将其传递给facebook API时,Facebook可以“抓取”它,并且可以将其作为新闻Feed故事等链接发布(因此机器可读,并显示非机器的相关内容!)

It should pass the test here: http://developers.facebook.com/tools/debug 它应该通过测试: http//developers.facebook.com/tools/debug

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM