Html 允许 1 个 Facebook 应用的多个域(如 Tumblr)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18511321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:47:47  来源:igfitidea点击:

Allowing multiple domains for 1 Facebook App (like Tumblr)

facebookhtmlfacebook-graph-apifacebook-opengraph

提问by stikkos

I am trying to get my website validated with the Facebook object debugger and I'm running into the following error:

我正在尝试使用 Facebook 对象调试器验证我的网站,但遇到以下错误:

Object at URL 'http://www.example.com/latest' of type 'smallteaser:teaser' is invalid because the domain 'www.example.com' is not allowed for the specified application id '597566643589666'.

URL ' http://www.example.com/latest' 类型为 'smallteaser:teaser' 的对象无效,因为域 'www.example.com' 不允许用于指定的应用程序 ID '597566643589666'。

This error makes perfect sense since I haven't allowed the example.com domain specific access to the Facebook app. But do I really have to?

这个错误是完全合理的,因为我没有允许 example.com 域特定访问 Facebook 应用程序。但我真的必须这样做吗?

What I would like to achieve is similar to how Tumblr works when a custom domain is used. Say, for example, the website www.davidslog.com: it has the following meta tags:

我想要实现的目标类似于使用自定义域时 Tumblr 的工作方式。例如,网站www.davidslog.com:它具有以下元标记:

<meta property="fb:app_id" content="48119224995" />

   --> This is the Tumblr app ID


<meta property="og:url" content="http://www.davidslog.com/?og=1" />

   --> This is a custom domain which points to a Tumblr blog


<meta property="og:type" content="tumblr-feed:tumblelog" />

   --> This is a custom Tumblr object type (in namespace tumblr-feed)

And if you then compare this with, for instance, the domain theartofnotwriting.tumblr.com, which has the following metadata:

然后,如果您将其与域theartofnotwriting.tumblr.com进行比较,该域具有以下元数据:

<meta property="fb:app_id" content="48119224995">

   --> This is the same Tumblr app ID

<meta property="og:url" content="http://theartofnotwriting.tumblr.com/?og=1">

   --> This is a different domain

<meta property="og:type" content="tumblr-feed:tumblelog">

You can clearly see that the same Tumblr app has multiple URLs and everything validates correctly.

您可以清楚地看到同一个 Tumblr 应用程序有多个 URL,并且所有内容都经过正确验证。

So why is it that this Tumblr page validates correctly and mine doesn't? How can a Facebook app be configured to allow being used on multiple domains?

那么为什么这个 Tumblr 页面可以正确验证而我的却没有呢?如何配置 Facebook 应用以允许在多个域上使用?

回答by Jonathan Vanasco

I ran into this same issue. I figured that Tumblr must have some sort of partnership in place with Facebook to get this special treatment ( ip whitelist? special api? ) -- so I contacted my former Partnerships Rep at Facebook to enquire.

我遇到了同样的问题。我认为 Tumblr 必须与 Facebook 建立某种合作伙伴关系才能获得这种特殊待遇(ip 白名单?特殊 api?)——所以我联系了我在 Facebook 的前合作伙伴关系代表进行询问。

I got to speak with a platform engineer at Facebook about this, and I was totally wrong. There is nothing special going on.

我不得不与 Facebook 的一位平台工程师讨论此事,但我完全错了。没有什么特别的事情发生。

The reason why all the domains running on Tumblr are validating fine with a single app_id, is that the facebook debug tool only checks the validity of the og_tag's structure (at least when it comes to the app_id). It does not validate if the app_id is properly associated with the given domain.

在 Tumblr 上运行的所有域都可以通过单个 app_id 进行验证的原因是,facebook 调试工具仅检查 og_tag 结构的有效性(至少在涉及 app_id 时)。它不会验证 app_id 是否与给定域正确关联。

You can test this by putting up a test page with the your app_id on two different domains -- they'll both validate as fine in the debug tool.

您可以通过在两个不同的域上放置带有您的 app_id 的测试页面来测试这一点——它们都将在调试工具中验证为正常。

When it comes to actual Facebook API access, Tumblr does everything on their domain. When people do use Facebook buttons/etc on Tumblr, it is often through a third party proxy tool (like ShareThis) or with a non-api button embed. I couldn't find a single custom-domain running on Tumblr that used the Facebook API or app_id related buttons. If you can, I'd love to see it.

当涉及到实际的 Facebook API 访问时,Tumblr 在他们的域中做所有事情。当人们在 Tumblr 上使用 Facebook 按钮/等时,通常是通过第三方代理工具(如 ShareThis)或嵌入非 api 按钮。我找不到在 Tumblr 上运行的使用 Facebook API 或 app_id 相关按钮的单个自定义域。如果可以,我很想看。

It's the not answer you want (or I want) -- but that is what is happening. Tumblr's app_id appears on all the domains, but only actually works on ".tumblr.com"; The Facebook debug tool doesn't actually validate the app_id.

这不是你想要(或我想要)的答案——但这就是正在发生的事情。Tumblr 的 app_id 出现在所有域中,但实际上只适用于“.tumblr.com”;Facebook 调试工具实际上并不验证 app_id。

回答by peterhry

How can a Facebook app be configured to allow being used on multiple domains?

如何配置 Facebook 应用以允许在多个域上使用?

If you try to add more than one domain in the app settings, you get an error that looks like this:

如果您尝试在应用设置中添加多个域,则会收到如下错误消息:

example.commust be derived from one of: Site URL, Mobile Site URL, Canvas URL, Secure Canvas URL, Page Tab URL or Secure Page Tab URL.

example.orgmust be derived from one of: Site URL, Mobile Site URL, Canvas URL, Secure Canvas URL, Page Tab URL or Secure Page Tab URL.

example.com必须源自以下之一:站点 URL、移动站点 URL、画布 URL、安全画布 URL、页面选项卡 URL 或安全页面选项卡 URL。

example.org必须源自以下之一:站点 URL、移动站点 URL、画布 URL、安全画布 URL、页面选项卡 URL 或安全页面选项卡 URL。

One solution is to set the "Page Tab URL" to a fake URL on example.orglike so:

一种解决方案是将“页面标签 URL”设置为example.org上的假 URL,如下所示:

example.org/myfakepage

example.org/myfakepage

You don't actually have to use the page tab for anything. This just allows you to add a second domain.

您实际上不必使用页面选项卡进行任何操作。这只是允许您添加第二个域。

回答by CBroe

How can a facebook app be configured to allow being used on multiple domains?

如何将 Facebook 应用程序配置为允许在多个域上使用?

It can't. Facebook apps are tied to one domain (and subdomains thereof).

它不能。Facebook 应用程序绑定到一个域(及其子域)。

Imagine what would happen otherwise – someone could add lots of (big) websites to one single app, and then f.e. embed the JS SDK on each of them, and recognize a user that is connected to that app over “half the internet” … and thereby track their (almost) every step.

想象一下,否则会发生什么——有人可以将许多(大)网站添加到一个应用程序中,然后将 JS SDK 嵌入每个网站,并识别通过“一半的互联网”连接到该应用程序的用户……和从而跟踪他们(几乎)每一步。

Facebook of course does not want this1 – because theywant to make money of the data they collect about users and their movements through the web (they can in theory track you on every single website that uses a simple like button) – they would be stupid if they gave that same ability to every app developer.

Facebook当然不想要这个1——因为他们想从他们收集的关于用户和他们通过网络的活动的数据中赚钱(他们理论上可以在每个使用简单的类似按钮的网站上跟踪你)——他们会很愚蠢如果他们为每个应用程序开发人员提供相同的能力。

1 OK, that's my own assumption.

1 好吧,这是我自己的假设。

回答by brunocascio

You cannot add multiple domains, unless the domains differ only by extension or subdomain.

您不能添加多个域,除非域仅因扩展名或子域而异。

In the example below, cuponeadosdiffers only by domain extension (.comvs .com.ar), so both cuponeados.com.arand cuponeados.comare allowed:

在下面的例子,cuponeados不同之处仅由域扩展(.comVS .com.ar),使两者cuponeados.com.arcuponeados.com被允许:

enter image description here

在此处输入图片说明

See this answer here: Need to add multiple domains in a single Facebook Application

在此处查看此答案:需要在单个 Facebook 应用程序中添加多个域

回答by Odis Harkins

The way Tumbler does this is to allow sub domains under their domain using *.example.com. This will permit all the sub-domains to work with their app (like odisharkins.example.com, facebook.example.com). There are certain aspects to adding several domains: look at the Facebook Blog.

Tumbler 这样做的方法是使用 *.example.com 允许其域下的子域。这将允许所有子域与他们的应用程序一起使用(如 odisharkins.example.com、facebook.example.com)。添加多个域有某些方面:查看Facebook 博客

Further domains must be derived from one of: Site URL, Mobile Site URL, Canvas URL, Secure Canvas URL, Page Tab URL or Secure Page Tab URL.

其他域必须来自以下之一:站点 URL、移动站点 URL、画布 URL、安全画布 URL、页面选项卡 URL 或安全页面选项卡 URL

odisharkins.tumbler.com would not be an issue: it would work fine!

odisharkins.tumbler.com 不会有问题:它会正常工作!

However, harkinstech.com or odisharkins.com will not work.

但是,harkinstech.com 或 odisharkins.com 将不起作用。

回答by Tico Fortes

Worked for me: "The trick is to specify multiple app domains and use a comma separated list of valid URL's for the website URL configuration."

为我工作:“诀窍是指定多个应用程序域并使用逗号分隔的有效 URL 列表进行网站 URL 配置。”

https://www.sitepoint.com/community/t/single-facebook-app-with-multiple-domains/99834/4

https://www.sitepoint.com/community/t/single-facebook-app-with-multiple-domains/99834/4

回答by tattvamasi

  1. Go to developers.facebook.com.
  2. Click on your application and edit the settings.
  3. Add domains to that in the following form: example.com, example.org, subdomain.example.com (no http).
  4. Save.
  1. 访问 developer.facebook.com。
  2. 单击您的应用程序并编辑设置。
  3. 以以下形式向其中添加域:example.com、example.org、subdomain.example.com(无 http)。
  4. 节省。

That's the only way to do it, at east for the present time. You either add domains (and subdomains) manually or you can't proceed.

这是目前唯一的方法,在东方。您要么手动添加域(和子域),要么无法继续。