动态 OpenGraph 对象 URL 不起作用

发布于 2025-01-02 01:17:27 字数 599 浏览 2 评论 0原文

我正在尝试发布开放图活动。实际上它正在使用静态 .html 文件。但如果我指向带有 url 参数的 url,我会收到错误。两个页面的源代码 100% 相同,相信我。

# Dynamic call
/me/somesandbox:drive?car=http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car

# Static call
/me/somesandbox:drive?car=http://www.domain.com/static_car.html

错误:
“URL 上的对象 'http://www.domain.com/object/?og 'website' 类型的 :type' 无效,因为未提供 'string' 类型的必需属性 'og:type'。”

如果查看错误,您会看到,Facebook 没有获得完整的 url。参数丢失了,对吧。请帮忙!

I am trying to post an open graph activity. Actually it's working with a static .html file. But if i point to a url with url params i get an error. The sourcecode on both pages is 100% the same, trust me.

# Dynamic call
/me/somesandbox:drive?car=http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car

# Static call
/me/somesandbox:drive?car=http://www.domain.com/static_car.html

Error:
"Object at URL 'http://www.domain.com/object/?og:type' of type 'website' is invalid because a required property 'og:type' of type 'string' was not provided."

If you look at the error, you ll see, that Facebook didnt get the whole url. The params are missing, right. Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

土豪 2025-01-09 01:17:27

您尝试使用的 Open Graph 对象 url 是这个吗?

http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car

我的猜测是,因为 Facebook 已经在解析 : 冒号字符操作名称(即graph.facebook.com/me/recipebox:cook?recipe=),将它们用作您自己的参数可能不安全。

另外,可能存在一些混乱:据我所知,对象的 Open Graph 属性不会在像 og:title=Some%20car 这样的 URL 中传递。它们实际上在 URL 指向的页面中通过 开放图元标记。因此,如果您尝试使用 URL 设置对象属性,它将不起作用。

不要忘记使用Lint 调试工具来测试您的开放图谱对象URL!

不过,您可能确实知道这一点,并且只是使用 URL 的 GET 参数来设置 meta 标记。像这样的东西吗?

<meta property="og:title" content="<? echo $_GET['og:title'] ?>" />

如果是这种情况,只需尝试不使用 : 冒号即可。关于它们在 URL 中是否安全存在一些争论 ,但如果 Facebook 也在解析它们,那么最安全的方法就是将它们排除在外,如下所示:

// http://www.domain.com/object/?ogtype=somesandbox:car&ogtitle=Some%20car
<meta property="og:type" content="<? echo $_GET['ogtype'] ?>" />
<meta property="og:title" content="<? echo $_GET['ogtitle'] ?>" />

我还没有对此进行测试,只是给出了一些尝试建议。祝你好运!

The Open Graph object url you are trying to use is this?

http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car

My guess is, since Facebook is already parsing : colon characters for the action names (i.e. graph.facebook.com/me/recipebox:cook?recipe=), they might not be safe to use as your own parameters.

Also, there might be some confusion: so far as I know, Open Graph properties of objects are not passed in URLs like this og:title=Some%20car. They are actually uncoded in the page the URL points to, via the open graph meta tags: <meta property="og:title" content="Some car" />. So if you trying to set the Object properties with the URL, it won't work.

Don't forget to use the Lint Debug Tool to test out your Open Graph Object URLs!

You probably do know this, though, and are just using the URL's GET parameters to set the meta tags. Something like this?

<meta property="og:title" content="<? echo $_GET['og:title'] ?>" />

If this is the case, just try it without the : colons. There is some debate about whether they are safe in URLs anyway, but if Facebook is also parsing them it'll be safest to just leave them out, like this:

// http://www.domain.com/object/?ogtype=somesandbox:car&ogtitle=Some%20car
<meta property="og:type" content="<? echo $_GET['ogtype'] ?>" />
<meta property="og:title" content="<? echo $_GET['ogtitle'] ?>" />

I have not tested this, just giving some suggestions to try. Good luck!

も让我眼熟你 2025-01-09 01:17:27

Facebook 有一个很好的工具来了解 facebook 看到的内容: https://developers.facebook.com/tools/ debug 只需输入网址,即可观看调试。

不要忘记,这些元标记必须放置在节中。

Facebook has this nice tool to find out what the facebook see: https://developers.facebook.com/tools/debug just put the url, and watch the debug.

Don't forget, these meta tags have to be placed in section.

夏有森光若流苏 2025-01-09 01:17:27

知道了。
@thaddeusmt:已经走上正轨了。

这是非常重要的 - 当然是 - 你必须对URIComponent(yoururl?with=vars)进行编码

已解决

如果你像这样传递你的网址:

/me/somesandbox:drive?car=http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car

确保对 object-url 进行编码。例如使用 JavaScript

encodeURIComponent(http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car)

Got it.
@thaddeusmt: Was already on the right track.

Which it super important - of course it is - you have to encodeURIComponent(yoururl?with=vars)

Solved

If you pass your url like this:

/me/somesandbox:drive?car=http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car

Make sure to encode the object-url. E.g. with Javascript

encodeURIComponent(http://www.domain.com/object/?og:type=somesandbox:car&og:title=Some%20car)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文