![](/img/trans.png)
[英]How can I get an instagram business account with Facebook Graph API?
[英]How to create a jsonpath to instagram business account in a batch request with the Graph API?
我的目标是创建具有相关调用的批处理请求,如此处所述: https : //developers.facebook.com/docs/graph-api/making-multiple-requests#operations
除了查询字符串参数之外,您还可以在表单发布参数中使用JSONPath引用先前操作的结果。 当数据数组中有多个具有instagram_business_account.id(iba_id)的元素时,我无法获得正确的JSONPath来使其正常工作
我要拨打的两个电话是/ me / accounts?fields = instagram_business_account /17841400714813297?fields=business_discovery.username(thomasguntenaar){media_count}我的批处理看起来像
[
{"method":"GET","name":"get-ig", "relative_url":"me/accounts?fields=instagram_business_account"},
{"method":"GET", "relative_url":"{result=get-ig:$.data..instagram_business_account.id}?fields=business_discovery.username(thomasguntenaar){media_count}}"}
]
在第二个查询中,您应该将JSONPath放到result=
后的instagram商业帐户ID中,我得到此错误
{
"code": 404,
"body": "{
\"error\": {
\"message\": \"(#803) Some of the aliases you requested do not exist: 17841400714813297,17841403388404550,17841401383243593\",
\"type\": \"OAuthException\",
\"code\": 803,
\"fbtrace_id\": \"FV8qA+oA7fp\"
}
}"
}
首次通话后的Facebook JSON响应为
{
"data": [
{
"id": "466912700123917"
},
{
"id": "502655553273897"
},
{
"instagram_business_account": {
"id": "17841400714813297"
},
"id": "503124266815195"
},
{
"instagram_business_account": {
"id": "17841403388404550"
},
"id": "510613645695833"
},
{
"instagram_business_account": {
"id": "17841401383243593"
},
"id": "2061834074114937"
}
],
"paging": {
"cursors": {
"before": "NDY2OTEyNzAwMTIzOTE3",
"after": "MjA2MTgzNDA3NDExNDkzNwZDZD"
}
}
}
当您像这样查询第二个请求时?ids=17841400714813297,17841403388404550,17841401383243593&fields=business_discovery.username(thomasguntenaar){username,media_count}
,响应看起来像这样
{
"17841400714813297": {
"business_discovery": {
"username": "thomasguntenaar",
"media_count": 76,
"id": "17841400714813297"
},
"id": "17841400714813297"
},
"17841403388404550": {
"business_discovery": {
"username": "thomasguntenaar",
"media_count": 76,
"id": "17841400714813297"
},
"id": "17841403388404550"
},
"17841401383243593": {
"business_discovery": {
"username": "thomasguntenaar",
"media_count": 76,
"id": "17841400714813297"
},
"id": "17841401383243593"
}
}
(#803)您请求的某些别名不存在:17841400714813297,17841403388404550,17841401383243593
显然,API认为这应该是一个 id,却没有意识到它应该是三个单独的id。
该API具有一种语法,可以在一个请求中请求多个对象的数据-可以使用/{id}?fields=foo
?ids={1,2,3}&fields=foo
的形式来代替/{id}?fields=foo
?ids={1,2,3}&fields=foo
,一次请求ID为1、2和3的对象的数据。 结果数据结构将包含每个id的子结构。
动态插入部件(此处是上一查询返回的IG帐户ID)时,相同的结构也应在批处理请求中起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.