Google Apps脚本进行HTTP POST

编程入门 行业动态 更新时间:2024-10-28 12:30:25
本文介绍了Google Apps脚本进行HTTP POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用Google Apps脚本进行HTTP POST. 我发现的文档很少,也许有人可以帮忙吗?

I would like to make an HTTP POST using google apps script. I have found very little documentation on this, maybe someone could kindly help?

HTTP POST将发送到名为"Twilio"的服务:

The HTTP POST will be to a service called 'Twilio':

www.twilio/docs/api/rest/发送短信

页面上说我在POST中只需要三个参数:

The page says I only need three parameters in my POST:

  • 发件人"号码
  • 收件人"号码
  • 身体"

我希望HTTP Post能够调用Twilio发送短信.

I am hoping that the HTTP Post will invoke Twilio to send an sms.

最后,我想从Google电子表格中获取这些参数.我可以自己做,因为我对Apps脚本相当满意,但是我从来没有做过HTTP POST,所以现在(为了简单起见),我自己将这些参数键入代码中.

In the end I want to get these parameters from a google spreadsheet. I can do that myself as I'm fairly comfortable with Apps Script but I've never done an HTTP POST, so for now (and for the sake of simplicity) I'll just type these parameters into the code myself.

如果有人知道如何执行此操作,或者使用Apps Script进行任何类型的HTTP POST,请让我知道-我已经花费了数小时试图弄清楚这一点!

If anyone knows how to do this, or make any sort of HTTP POST with Apps Script, please let me know - I've spent hours trying to figure this one out!

推荐答案

我设法做到了,这是代码:

i managed to do it, here's the code:

var url = "api.twilio/2010-04-01/Accounts/ ...account.SID... /SMS/Messages.json"; var options = { "method": "post", "headers": { "Authorization": "Basic " + Utilities.base64Encode(" ...account.SID... : ...auth.token... ") }, "payload": { "From": "+12025551212", "To": "+14155551212", "Body": "Test from Google Apps Script" } }; var response = UrlFetchApp.fetch(url, options);

更多推荐

Google Apps脚本进行HTTP POST

本文发布于:2023-10-12 00:29:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   Apps   Google   HTTP   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!