Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用post方法的Facebook Graph API批处理请求_Javascript_Node.js_Facebook_Facebook Graph Api_Messenger - Fatal编程技术网

Javascript 使用post方法的Facebook Graph API批处理请求

Javascript 使用post方法的Facebook Graph API批处理请求,javascript,node.js,facebook,facebook-graph-api,messenger,Javascript,Node.js,Facebook,Facebook Graph Api,Messenger,我正在尝试使用axios发送带有graph api批处理请求的批处理请求。 当我尝试与邮递员,我尝试了以下- 我试图发布一个带有批处理请求的发送api url = https://graph.facebook.com?access_token=EA...`. raw body = `{ "batch":[ { "method": "POST", "relative_url": "me/messages?access_token=<ACCESS_TOKEN>

我正在尝试使用axios发送带有graph api批处理请求的批处理请求。 当我尝试与邮递员,我尝试了以下- 我试图发布一个带有批处理请求的发送api

url = https://graph.facebook.com?access_token=EA...`.
raw body  = `{
    "batch":[
  {
    "method": "POST",
    "relative_url": "me/messages?access_token=<ACCESS_TOKEN>",
    "body": "{ \"messaging_type\": \"MESSAGE_TAG\",\r\n         \"tag\": \"ISSUE_RESOLUTION\",\r\n        \"recipient\": {\r\n          \"id\": \"1111944272264076\"\r\n        },\r\n        \"message\": {\r\n          \"text\": \"hello, world!\"\r\n        }}"
  }
]
}

响应代码是200。我已经在正文中给出了收件人。

您不需要对整个正文进行URL编码。仅显示每个参数的内容。请尝试将此作为请求的正文:

{
 "batch":[
  {
   "method":"POST",
   "relative_url":"me/messages", 
   "body": "recipient={\"id\": \"1111944272264076\"}&message={\"text\": \"hello, world!\"}"
  }
 ]
}
注意:我没有进行URL编码,而是对字符进行了转义。使代码更具可读性

{
 "batch":[
  {
   "method":"POST",
   "relative_url":"me/messages", 
   "body": "recipient={\"id\": \"1111944272264076\"}&message={\"text\": \"hello, world!\"}"
  }
 ]
}