appscript api 无效内容
我正在尝试使用来自 https://whapi.io/ 的 Whatsapp API
使用邮递员,它没有显示错误 使用邮递员成功的结果
但是当我尝试通过创建自定义函数在 googlesheet appscript 中使用时
function whatsappSend() {
var myHeaders = {
"contentType": "application/json"
}
var raw = JSON.stringify({
"app": {
"id": "601154119177", //sender@api_key
"time": "1646716022", //sample_data
"data": {
"recipient": {
"id": "60133102649" //recipient number with country code
},
"message": [
{
"time": "1646716022",
"type": "text",
"value": "Hello World!11"
}
]
}
}
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
var res = UrlFetchApp.fetch("https://whapi.io/api/send", requestOptions);
console.log(res.toString())
}
它显示无效-content
{"msg":"invalid content","result":"error"}
那么如何创建工作 appscript 函数,以便使用此 api 发送? 谢谢
i'm trying to use whatsapp api from https://whapi.io/
using postman it show no error
result using postman success
but when I try to use in googlesheet appscript by creating custom function
function whatsappSend() {
var myHeaders = {
"contentType": "application/json"
}
var raw = JSON.stringify({
"app": {
"id": "601154119177", //sender@api_key
"time": "1646716022", //sample_data
"data": {
"recipient": {
"id": "60133102649" //recipient number with country code
},
"message": [
{
"time": "1646716022",
"type": "text",
"value": "Hello World!11"
}
]
}
}
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
var res = UrlFetchApp.fetch("https://whapi.io/api/send", requestOptions);
console.log(res.toString())
}
it show invalid-content
{"msg":"invalid content","result":"error"}
So how to create working appscript function, for sending using this api?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从这个文档来看,下面的修改如何?
修改后的脚本:
注意:
raw
的值。参考:
From this document, how about the following modification?
Modified script:
Note:
raw
again.Reference: