如何在 Facebook 批量 API 请求中指定 API 版本?
How do I specify the API version in a Facebook batch API request?
Facebook 批处理 API 请求允许调用者在单个 HTTP POST.
中指定多个 API 端点
post 被做成基数 URL: https://graph.facebook.com.
post 的正文包含一个 JSON 散列和相对 URLs 以在 "relative_url" 字段中调用,例如"me/feed".
如何在此调用中指定 API 版本?
比如打2.2版本的API,我是post到https://graph.facebook.com/v2.2/还是在relative_url中指定"v2.2/me/feed" ?
截至 2015 年 2 月 26 日,Facebook API 文档在这一点上并不清楚:
https://developers.facebook.com/docs/graph-api/making-multiple-requests
您可能必须输入相对 url 。这是营销批次 API 文档
中的 example
curl -F 'access_token=______'
-F 'test1=@./test1.jpg'
-F 'batch=[
{
"method": "POST",
"name": "create_creative",
"relative_url": "<API_VERSION>/act_187687683/adcreatives",
"attached_files": "test1",
"body": "title=Test title&body=Test body&link_url=http://www.test12345.com&image_file=test1.jpg"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/adgroups",
"body": "campaign_id=6004163746239&redownload=1&bid_type=CPC&bid_info={\"clicks\":150}&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"US\"]}&name=test1"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/adgroups",
"body": "campaign_id=6004163746239&redownload=1&bid_type=CPC&bid_info={\"clicks\":150}&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"GB\"]}&name=test2"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/adgroups",
"body": "campaign_id=6004163746239&redownload=1&bid_type=CPC&bid_info={\"clicks\":150}&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"IE\"]}&name=test3"
}
]' https://graph.facebook.com/
我假设这对其他请求也很常见。
各种其他阅读来源
1.) 来自here
Pre-pend the version identifier to the start of the request path. For
example, here's a call to v2.2:
GET graph.facebook.com
/v2.2/me
This works for all versions, in this general form:
GET graph.facebook.com
/vX.Y/{request-path}
2.) 放在url里好像是为了Dialogs and Social plugins
Dialogs
Versioned paths aren't just true for API endpoints, they're also true
for dialogs and social plugins. For example, if you want to generate
the Facebook Login dialog for a web app, you can prepend a version
number to the endpoint that generates the dialog:
https://www.facebook.com/v2.0/dialog/oauth?
client_id={app-id}
&redirect_uri={redirect-uri}
Social Plugins
If you're using the HTML5 or xfbml versions of our social plugins, the
version rendered will be determined by the version specified when
you're initialising the JavaScript SDK.
If you're inserting an iframe or plain link version of one of our
plugins, you'd prepend the version number to the source path of the
plugin:
<iframe
src="//www.facebook.com/v2.0/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width&layout=standard&action=like&show_faces=true&share=true&height=80&appId=634262946633418" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:80px;" allowTransparency="true"> </iframe>
Facebook 批处理 API 请求允许调用者在单个 HTTP POST.
中指定多个 API 端点post 被做成基数 URL: https://graph.facebook.com.
post 的正文包含一个 JSON 散列和相对 URLs 以在 "relative_url" 字段中调用,例如"me/feed".
如何在此调用中指定 API 版本?
比如打2.2版本的API,我是post到https://graph.facebook.com/v2.2/还是在relative_url中指定"v2.2/me/feed" ?
截至 2015 年 2 月 26 日,Facebook API 文档在这一点上并不清楚: https://developers.facebook.com/docs/graph-api/making-multiple-requests
您可能必须输入相对 url 。这是营销批次 API 文档
中的 examplecurl -F 'access_token=______'
-F 'test1=@./test1.jpg'
-F 'batch=[
{
"method": "POST",
"name": "create_creative",
"relative_url": "<API_VERSION>/act_187687683/adcreatives",
"attached_files": "test1",
"body": "title=Test title&body=Test body&link_url=http://www.test12345.com&image_file=test1.jpg"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/adgroups",
"body": "campaign_id=6004163746239&redownload=1&bid_type=CPC&bid_info={\"clicks\":150}&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"US\"]}&name=test1"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/adgroups",
"body": "campaign_id=6004163746239&redownload=1&bid_type=CPC&bid_info={\"clicks\":150}&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"GB\"]}&name=test2"
},
{
"method": "POST",
"relative_url": "<API_VERSION>/act_187687683/adgroups",
"body": "campaign_id=6004163746239&redownload=1&bid_type=CPC&bid_info={\"clicks\":150}&creative={\"creative_id\":\"{result=create_creative:$.id}\"}&targeting={\"countries\":[\"IE\"]}&name=test3"
}
]' https://graph.facebook.com/
我假设这对其他请求也很常见。
各种其他阅读来源
1.) 来自here
Pre-pend the version identifier to the start of the request path. For example, here's a call to v2.2:
GET graph.facebook.com /v2.2/me
This works for all versions, in this general form:
GET graph.facebook.com /vX.Y/{request-path}
2.) 放在url里好像是为了Dialogs and Social plugins
Dialogs
Versioned paths aren't just true for API endpoints, they're also true for dialogs and social plugins. For example, if you want to generate the Facebook Login dialog for a web app, you can prepend a version number to the endpoint that generates the dialog:
https://www.facebook.com/v2.0/dialog/oauth? client_id={app-id} &redirect_uri={redirect-uri}
Social Plugins
If you're using the HTML5 or xfbml versions of our social plugins, the version rendered will be determined by the version specified when you're initialising the JavaScript SDK.
If you're inserting an iframe or plain link version of one of our plugins, you'd prepend the version number to the source path of the plugin:
<iframe src="//www.facebook.com/v2.0/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width&layout=standard&action=like&show_faces=true&share=true&height=80&appId=634262946633418" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:80px;" allowTransparency="true"> </iframe>