Javascript 使用post方法的Facebook Graph API批处理请求
我正在尝试使用axios发送带有graph api批处理请求的批处理请求。 当我尝试与邮递员,我尝试了以下- 我试图发布一个带有批处理请求的发送apiJavascript 使用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>
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!\"}"
}
]
}