Facebook 开放图谱单页应用程序 [英] Facebook Open Graph Single Page Apps

查看:23
本文介绍了Facebook 开放图谱单页应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用主干 js 构建了一个单页应用程序.对于各种应用程序状态和动态内容(例如书籍),我有单独的主干 URL路由",但本质上 Facebook 只会看到索引页面.

I have built a single page application using backbone js. I have separate backbone url "routes" for various application states and dynamic content (e.g. books), but essentially Facebook will only ever see the index page.

以下 SO 问题似乎提供了一种有趣的方法来为动态内容提供物理开放图 URL:

The following SO question seems to provide an interesting approach to providing physical open graph URLs for dynamic content:

同一页面上的多个 Facebook opengraph 对象

其他开发者如何在动态页面上使用开放图标签,特别是在单页应用中?

How have other developers approached using open graph tags on dynamic pages, specifically in single page apps?

推荐答案

您可以让服务器为此输出动态内容,但您仍然需要为每个对象使用不同的 url,因为这是 facebook 索引这些对象的方式.

You can have the server output dynamic content for this, but you still need a different url for each object since this is how facebook index those objects.

然而,您可以做的是使用 url 的查询字符串或片段部分来识别它.因此,假设您有一个页面要为所有开放图形对象提供服务:your-domain.com/og 现在您可以向其中添加如下标识符:

What you can do however, is use the querystring or fragment parts of the url to identify it. So, let's say you have a single page that you want to serve all the open graph objects: your-domain.com/og now you can add to it identifiers like this:

your-domain.com/og?type=3&id=432543643
your-domain.com/og#type=653&id=46t43g3
your-domain.com/og?type=25id=4tn4g43#anotherstring

这篇关于Facebook 开放图谱单页应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆