我有谷歌表,我需要用WhatsApp发送数据,所以我有僵尸制造者的API。它们提供了一个cURL和JSON数据,但是我不知道如何使用cURL和JSON来完成post,使用一个google函数。
这是cURL:
curl
- X POST
--header 'Content-Type: multipart/form-data'
--header 'Accept: application/json'
--header 'access-token: myAccessToken'
-F chatPlatform=whatsapp
-F chatChannelNumber=############
-F platformContactId=############
-F mediaType=document这是API的请求URL:'https://go.botmaker.com/api/v1.0/message/binary/v3‘
这是响应体:无内容
这是响应代码: 401
响应头:
{
"accept": "[application/json, application/xml, text/plain]",
"access-control-allow-credentials": "true",
"access-control-allow-headers": "bearer-token,access-token,Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin",
"access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS, HEAD",
"access-control-allow-origin": "https://go.botmaker.com",
"alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
"cache-control": "must-revalidate,no-cache,no-store",
"content-length": "0",
"content-security-policy": "default-src 'self'",
"date": "Sat, 11 Jun 2022 22:52:02 GMT",
"permissions-policy": "geolocation=(self \"https://go.botmaker.com\"), microphone=()",
"reason-phrase": "Cannot authenticate user with received tokens after applying [access-token] and accessToken [null]",
"referrer-policy": "no-referrer",
"server": "Botmaker",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"via": "1.1 google",
"x-content-type-options": "nosniff",
"x-frame-options": "DENY"
}我知道我需要使用UrlFetchApp.fetch
有人能帮我创造
发布于 2022-06-14 01:09:11
我找到了路,下面是它对我的作用:
var userNumber = '123456789012' // to: cellular phone number
const waNumber = '123456789012'; // from: cellular phone
const accessToken = 'faketoken'; // use you token
// send a template
var url = 'https://go.botmaker.com/api/v1.0/intent/v2';
var headers = {
'Content-Type': 'application/json' ,
'Accept': 'application/json' ,
'access-token': accessToken
};
var dataJson = {
"chatPlatform": "whatsapp",
"chatChannelNumber": waNumber,
"platformContactId": userNumber,
"ruleNameOrId": "template_name" // the name of the template
};
var payload = JSON.stringify(dataJson);
var options = {
'method': 'POST',
'headers': headers,
'payload': payload
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);https://stackoverflow.com/questions/72588433
复制相似问题