Ric*_*ton 11 facebook facebook-graph-api
Facebook批量API请求允许调用者在单个HTTP POST中指定多个API端点.
该帖子是基于URL:https://graph.facebook.com.
帖子的主体包含一个JSON哈希,其中包含要在"relative_url"字段中调用的相对URL,例如"me/feed".
如何在此调用中指定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
Sla*_*ast 10
您可能需要输入相对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/
Run Code Online (Sandbox Code Playgroud)
我认为这也是其他请求的共同点.
各种其他阅读资源
1.)从这里开始
将版本标识符预先挂起到请求路径的开头.例如,这是对v2.2的调用:
Run Code Online (Sandbox Code Playgroud)GET graph.facebook.com /v2.2/me这适用于所有版本,采用以下一般形式:
Run Code Online (Sandbox Code Playgroud)GET graph.facebook.com /vX.Y/{request-path}
2.)将它放在URL中似乎是用于Dialogs和Social插件
对话框
版本化路径不仅适用于API端点,它们也适用于对话框和社交插件.例如,如果要为Web应用程序生成"Facebook登录"对话框,则可以在生成对话框的端点前面添加版本号:
Run Code Online (Sandbox Code Playgroud)https://www.facebook.com/v2.0/dialog/oauth? client_id={app-id} &redirect_uri={redirect-uri}社交插件
如果您使用的是社交插件的HTML5或xfbml版本,则呈现的版本将由您初始化JavaScript SDK时指定的版本决定.
如果您要插入我们其中一个插件的iframe或纯链接版本,则需要将版本号添加到插件的源路径中:
Run Code Online (Sandbox Code Playgroud)<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>
| 归档时间: |
|
| 查看次数: |
555 次 |
| 最近记录: |