Instagram OEmbed 问题 - OAuthException 200 提供有效的应用程序 ID

问题描述 投票:0回答:3

我在尝试使用 Instagram OEmbed 时遇到异常。

如本页所述: https://developers.facebook.com/docs/graph-api/reference/instagram-oembed/

我向此端点发送了 HTTP GET 请求:

https://graph.facebook.com/v12.0/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b/&app

如文档中所述,我使用“url”查询字符串参数。但是,我遇到了一个例外,例如:

{
    "error": {
        "message": "(#200) Provide valid app ID",
        "type": "OAuthException",
        "code": 200,
        "fbtrace_id": "Acr4on4TtEYPIc2RQwqNmDL"
    }
}

所以有一个错误明确指出我需要“提供有效的应用程序 ID”。但是,没有关于如何提供该应用程序 ID 的信息。我尝试过一些,包括:

https://graph.facebook.com/{app_id}/v12.0/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b/

https://graph.facebook.com/v12.0/{app_id}/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b/

没有运气。我期待着解决方案。

facebook-graph-api
3个回答
4
投票

正如 CBroe 在评论中指出的那样,您需要一个有效的访问令牌,您可以将其添加在网址末尾,如下所示:

https://graph.facebook.com/v12.0/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b?access_token=YOURTOKEN

您可以在此处查找更多文档: https://developers.facebook.com/docs/graph-api/overview/


0
投票

由于这没有解决我的问题,我将发布我的解决方案。

一个关键的区别是我正在使用 SDK,而海报似乎正在自己处理 url。

FacebookAdsApi.init(
                access_token=credentials.password
            )
response = AdAccount(self.ad_account_id).get_insights(
                **request_kwargs
            )

如果您正在处理这样的请求,请确保指定

access_token=xxx
,因为令牌是 kwarg。在初始化期间直接传递令牌而不指定
access_token
不会抛出错误,直到您实际发出请求。然而,大多数其他初始化问题都会引发错误。因此,很容易让人误以为初始化不是问题,而实际上它是问题。


0
投票

我不知道你的情况是否相同,但我意识到这个问题是因为我没有正确传递我的令牌而引起的,如下所示:

response = Http::withHeaders([
        'Authorization' => 'Bearer' . $pageAccessToken,
    ])->get($url);

当我像上面那样做时,我得到了错误,因为我没有在“承载者”和我的令牌之间留出空间,所以我这样做了:

response = Http::withHeaders([
        'Authorization' => 'Bearer ' . $pageAccessToken,
    ])->get($url);

效果很好

© www.soinside.com 2019 - 2024. All rights reserved.