Facebook批量API请求允许调用者在单个HTTP POST中指定多个API端点。
帖子发布到基本网址: https://graph.facebook.com。
帖子的主体包含一个JSON哈希,其中包含要在“relative_url”字段中调用的相对URL,例如“我/饲料”。
如何在此调用中指定API版本?
例如,要点击2.2版本的API,我会发布到 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文档
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.)来自 这里
将版本标识符预先挂起到请求路径的开头。对于
例如,这是对v2.2的调用:
GET graph.facebook.com
/v2.2/me
这适用于所有版本,采用以下一般形式:
GET graph.facebook.com
/vX.Y/{request-path}
2.)把它放在网址似乎是为了 对话框和社交插件
对话框
版本化路径不仅适用于API端点,它们也是如此
对话框和社交插件。例如,如果要生成
Web应用程序的Facebook登录对话框,您可以添加一个版本
编号到生成对话框的端点:
https://www.facebook.com/v2.0/dialog/oauth?
client_id={app-id}
&redirect_uri={redirect-uri}
社交插件
如果您正在使用社交插件的HTML5或xfbml版本,那么
呈现的版本将由指定的版本确定
你正在初始化JavaScript SDK。
如果您要插入我们之一的iframe或纯链接版本
插件,您将版本号添加到的源路径
插入:
<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>