为 Instagram oneboxes 配置应用令牌

:warning: 自本指南最初撰写以来所做的重要更新:

  1. 现已要求应用审核 (App Review)。 自 2021 年 9 月起,Meta 要求您的应用通过 App Review 并获得 oEmbed Read 权限的批准(对于 2025 年 4 月 8 日之后创建的应用,现称为 Meta oEmbed Read)。如果没有此权限,oEmbed API 调用将会失败。请参阅 Meta 的 App Review 提交指南 以获取批准方面的提示。

  2. Instagram 聚合卡片 (onebox) 可能无法正确渲染。 自 2025 年 11 月 3 日起,Meta 从 Instagram oEmbed 响应中删除了 thumbnail_urlthumbnail_widththumbnail_heightauthor_name 字段。Discourse 目前的 Instagram onebox 代码依赖于这些字段(lib/onebox/engine/instagram_onebox.rb),这可能导致嵌入内容损坏或为空。

  3. 仅支持帖子和 IGTV URL。 Discourse 目前仅对 Instagram 的 /p/ (帖子) 和 /tv/ (IGTV) URL 生成 onebox。Reels (/reel/) URL 不受支持。

  4. Facebook 开发者控制台的用户界面自下面截图于 2020 年 12 月拍摄以来已发生重大变化。基本步骤仍然相似,但确切的屏幕和选项可能看起来不同。


如果您已经有一个与您的 Discourse 网站关联的 Facebook 应用,请滚动到 向您的 Facebook 应用添加 oEmbed

如果您没有 Facebook 开发者账户和 Facebook 应用:

访问 https://developers.facebook.com/。如果您尚未登录,系统会提示您登录您的 Facebook 账户。如果您以前没有将您的 Facebook 账户转换为开发者账户,系统可能会要求您“转换”。您可能需要通过添加电话号码或完成其他步骤来用 Facebook 验证您的账户。您只需按照提示操作并完成 Facebook 对您的要求即可。

拥有 Facebook 开发者账户后,从 Facebook 开发者主屏幕点击“我的应用”:

…然后点击“创建应用”:

选择“其他 (Something Else)”作为应用类型,然后点击“继续 (Continue)”:

输入“应用展示名称 (App Display Name)”和“应用联系邮箱 (App Contact Email)”。在阅读完其条款和政策后,您可以点击“创建应用 (Create App)”:

如果您是机器人:这里没什么可看的。哔啵嘟嘟。:robot:

如果您不是机器人:点击“我不是机器人 (I’m not a robot)”,按照提示操作,然后点击“提交 (Submit)”。

恭喜!您有了一个 Facebook 应用!

向您的 Facebook 应用添加 oEmbed:

滚动到“产品 (Products)”列表的底部,找到“oEmbed”并点击“设置 (Set Up)”:

如果您同意您将如何使用 oEmbed 产品,请选中复选框,然后点击“确认 (Confirm)”:

oEmbed 产品已添加。点击“设置 (Settings)”:

“展示名称 (Display Name)”和“联系邮箱 (Contact Email)”应该已经填好了。您需要输入您的“隐私政策 (Privacy Policy)”和“服务条款 (Terms of Service)”的 URL。从可用选项列表中选择一个“类别 (Category)”。对所有内容满意后,点击“保存更改 (Save Changes)”:

点击屏幕顶部的切换开关,将模式从“开发中 (In development)”更改为“上线 (Live)”:

点击“切换模式 (Switch Mode)”:

提交您的应用以进行应用审核(自 2021 年起要求):

在您的应用可以访问生产环境中的 oEmbed API 之前,您必须提交它进行应用审核,并请求 oEmbed Read 权限(对于 2025 年 4 月 8 日之后创建的应用,则为 Meta oEmbed Read)。

  1. 在应用的仪表板中,转到 App ReviewPermissions and Features(应用审核 → 权限和功能)。
  2. 找到 oEmbed Read(或 Meta oEmbed Read)并点击 Request(请求)。
  3. 您可能需要先成功进行一次测试 API 调用,请求按钮才会变为可操作状态。这可能在您的首次 API 调用后最多需要 24 小时。
  4. 提交时,请提供一个包含 Instagram 嵌入内容的 Discourse 网站 URL,并解释您的网站使用 Discourse 论坛软件通过 oEmbed API 嵌入 Instagram 帖子。

有关详细的提交指南,请参阅 Meta 的 oEmbed 文档

生成您的应用访问令牌:

完成所有这些操作后,我们可以按照 Facebook 关于 应用访问令牌 的说明来实际生成应用令牌。您需要“应用 ID (App ID)”字段的值以及“应用密钥 (App Secret)”字段的值。要获取应用密钥,请点击“显示 (Show)”。系统可能要求您重新验证身份或执行类似操作,但最终您应该会得到一个可以复制的长十六进制值:

根据 Facebook 的文档,您需要将这些值发送给 Facebook 以生成令牌。您是否熟悉使用 curl?太棒了!他们建议使用以下命令(将 {your-app-id}{your-app-secret} 替换为您从上面屏幕复制的值)。

curl -X GET "https://graph.facebook.com/oauth/access_token?client_id={your-app-id}\u0026client_secret={your-app-secret}\u0026grant_type=client_credentials"

或者,将仅 URL(替换那两个值后)复制到浏览器中也应该有效:

https://graph.facebook.com/oauth/access_token?client_id={your-app-id}\u0026client_secret={your-app-secret}\u0026grant_type=client_credentials

Facebook 将以一小段 JSON 响应,它应该看起来像下面的示例:

{"access_token":"1234567890654321|c3bd55c09fc5e561552ad7a8717","token_type":"bearer"}

复制您的 access_token 的值,不包括引号(例如,在我的示例中是 1234567890654321|c3bd55c09fc5e561552ad7a8717),然后转到您的 Discourse 网站的设置。在 Onebox 设置中找到名为 facebook_app_access_token 的站点设置。将 access_token 值粘贴到此字段中:

点击 :white_check_mark: …大功告成!

在您的网站帖子中粘贴一个 URL,例如 https://www.instagram.com/p/CIRhYzFM7Lu/,应该会显示一个漂亮的 onebox,就像这个一样:

https://www.instagram.com/p/CIRhYzFM7Lu/

17 个赞

New oEmbed Read Feature and App Review Requirements

Today, June 8, 2021, we announced v11.0 of the Graph API and Marketing APIs. With this update, there are new requirements to be able to access oEmbed APIs . Some of your apps currently access the oEmbed APIs and might be affected by these changes.

To continue accessing the oEmbed APIs, you will have to submit your apps for review by September 6th, 2021 . If you want to request new access to the oEmbed APIs, you will also need to submit your app(s) for review.

To learn more, please review the updated requirements. If your apps haven’t been reviewed for the oEmbed API feature by September 6, 2021, your apps will lose access to this feature. To avoid disruption to your apps’ oEmbed access, please submit for App Review as soon as possible.

New rules from our Facebook overlords, I’ve just submitted both of my apps for review. I found a public post with an Instagram embed and linked directly to show how the integration works. Hopefully this is sufficient.

8 个赞


womp womp, review failed.

here’s what i submitted

Your submission details

Is a Facebook reviewer able to access or login to your app to verify you’re using permissions or features according to Facebook Platform Policy?

Yes

Platform Settings

Desktop

Site URL:https://fixed.org.au/

No account needed

  1. Visit The 'what you've done to your bike today' thread - #10218 by jaseyjase - Post your ride - FOA
  2. The instagram post is embeded in the page. The site is running Discourse forum software (https://discourse.org/)

Oembed Read

Tell us how you’re using this permission or feature

Discourse (https://discourse.org/) can embed Instagram and Facebook posts in community posts, it keeps people on our website while richly embedding content

Oembed URL

The 'what you've done to your bike today' thread - #10218 by jaseyjase - Post your ride - FOA

I just resubmitted (had some extra text in Oembed URL) and it’s been approved!!! :smiley: waiting for my second app to be…

3 个赞

The text looks the same as in your initial review submit. Can you elaborate on what extra information you provided compared to the failed review?

In addition: Did you pass FB login data to the forum or not?

1 个赞

@znedw my question still stands, if you can help everyone with some insight on this please?

The first review failed because I had some extra text in the Oembed URL field and the form removes spaces onsubmit, so the URL didn’t work… That’s the only difference between attemps

Nope, in the Platform section (I had to add a platform in the wizard), I just wrote

No account needed

I didn’t really want to setup a discourse account just for FB review, so I just found a post on our forum that was public, and had an Instagram image embedded. I thought this would show how the integration functions well enough. I guess FB could read the discourse source and work it out themselves :man_shrugging:

Sorry I missed this. I literally did no changes to either forum, just found a forum post with an instagram pic embedded as mentioned above and then walked through the app review wizard on FB

3 个赞

Hi @znedw, I followed your guide and got our app review approved 24 hours later.

Although, I had to enter the direct link to the embedded Instagram post into the oEmbed-URL field as the form did not accept the link to the topic on our domain in that field. Maybe they changed that part.

For the rest, I followed exactly your wording. And it worked.

1 个赞

快速提问:流程是否已更改为“Instagram 基本显示”或是我眼瞎了?因为我找不到 oEmbed 选项,按定义最接近的是我猜的 Instagram 基本显示。

引用:

Instagram 基本显示允许应用访问 Instagram 基本显示 API,该 API 提供对应用用户 Instagram 帐户基本数据的只读访问。

使用此选项卡可配置 API 的 授权窗口,以便您可以从用户那里获得 权限,并在准备好将应用切换到实时模式时提交 应用审核

请注意,基本显示不是身份验证工具。API 返回的数据不能用于验证您的应用用户或让他们登录您的应用。如果您的应用使用 API 数据来验证用户,它将在应用审核期间被拒绝。如果您需要身份验证解决方案,请改用 Facebook 登录

但是,它需要此处未列出的其他 URL,所以我不太确定,例如:

客户端 OAuth 设置

取消授权回调 URL


(另外,也许有什么东西改变了,因为它在这里不起作用,我想?)

https://www.instagram.com/p/CIRhYzFM7Lu

3 个赞

据我所知,它仍然是 oEmbed readadvanced access

1 个赞

明白了。那和教程就有区别了。

它不再像其他功能(在用户界面中称为“产品”)那样从仪表板添加,而是从“应用审核”菜单的“请求”部分进行请求。您选择该功能并将其提交审核。

这使得该过程有点像漏洞,因为他们要求提供一个有效的 oEmbed 链接才能批准它……但这不起作用,因为该功能尚未获得批准……:sweat:

4 个赞

我的帐户现在可以正常工作了。我会尝试总结你需要的内容。我不太懂技术,所以不确定能否回答很多问题,但我想你可以尽量复制我的设置来检查是否都能正常工作。

你需要 Facebook 登录(我不知道是否真的需要 Instagram Graph API)。请检查你的 Discourse 安装上的 Facebook 登录是否正常工作。

Facebook 登录设置:

基本设置:

高级设置:

3 个赞

大家好,想告诉大家的是,从今天起,@Iceman 的描述仍然准确。

一些页面布局已根据指南 (:point_up:) 修改,但主要区别在于 oEmbed 必须在您的应用通过应用审核 之后 才能请求。

在“应用审核”菜单中,您可以提出请求:

我的应用尚未通过应用审核,但 @undasein 在本指南的帮助下,并根据 https://stackoverflow.com/questions/67998234/starting-using-instagram-oembed-feature 的建议,最近成功使其生效。


祝大家分享 grams 顺利!:slight_smile:

3 个赞

我的请求很简单,我只是写了“我想在我的论坛上嵌入 Instagram帖子”,一天就获得了批准。

1 个赞

我该如何访问高级 oembed 读取?我甚至无法请求它,因为按钮被禁用了。我在图上做了一些 API 调用,但即使过了 24 小时也没有任何反应。

一些用户通过因其他原因(例如 Facebook 登录)提交应用进行审核来解决此问题,一旦获得批准,就可以请求某些功能,例如“Oembed Read”。

您可能需要联系平台支持渠道以了解您帐户的情况。 :+1:

1 个赞

[quote=“Jamie Wilson, post:1, topic:223548, username:jamie.wilson”]noEmbed
[/quote]

noEmbed 不再存在,我应该改用什么?

[quote=“Iceman, post:10, topic:223548, username:Iceman”]Instagram Basic Display
[/quote]

我看不到 Oembed 选项,你选了哪一个?

@danielabc,您的应用通过应用审核了吗?

1 个赞

当我进入选项时,按钮是关闭的,我无法点击

当我进入选项时,按钮是关闭的,我无法点击

我的访问权限因 90 天未使用而被撤销。这意味着,我认为,我的论坛上没有人最近发布过 Instagram 链接。

因此,oEmbed 读取权限的当前状态如下:

要请求此权限的高级访问权限,您需要进行一次成功的 API 测试调用。在首次 API 调用后的 24 小时内,此按钮才会变为活动状态。了解测试

在这种情况下,我们如何在 Discourse 中实际进行 API 调用以再次请求高级访问权限? :thinking:

2 个赞