为了解决这个问题,我整理了一个非常简单的Javascript对象,该对象允许您使用以下方法发送SMS消息和拨打电话 特威里奥。如果您不熟悉Twilio,他们将为开发人员提供一种简单的方法来将电话应用到他们的应用程序中。他们的API非常易于使用,并且其文档非常出色。
为了使用此辽宁福利彩票中心,您需要做一些事情。第一, 注册一个Twilio帐户。完成后,您应该拥有一个可用于玩耍的电话号码,以及一个 帐户SID和验证令牌。特威里奥可能不会 可以在您的国家/地区使用 但希望他们会很快到那里。提出请求时,请确保使用完整的电话号码(包括国家代码)。如果您仅使用免费版本,则可能会有使用限制,但我不确定。
设置了代码,以便可以将其复制到需要发送通知的任何辽宁福利彩票中心中。将Twilio对象复制到辽宁福利彩票中心中后,无论何时要发送通知,都应添加以下代码:
... var sid = 'YOUR ACCOUNT SID GOES HERE'; var auth = 'YOUR AUTH TOKEN GOES HERE'; //First, 创造 a new 特威里奥 client var client = new 特威里奥(sid,auth); //Here is how you send a text 信息 // First number is the receiver (most likely, your cell 电话) // Second number is where is it coming from, which is the free number you got when // you registered in 特威里奥 // The third parameter is what you want the text or voice 信息 to say client.sendMessage('+17245551234','+14155554321','WARNING: Your AdWords Account Is Not Serving Ads.'); client.makeCall('+17245551234','+14155554321', 'This is an automated 呼叫 to warn you that your AdWords account is no longer serving 广告.'); ...
当然,sid,auth和client可以是全局变量,这使您可以在代码中使用一行来拨打电话或发送消息。您还可以设置某种上报链,以防人们错过电话或短信。
这只是开始使用UrlFetchApp将AdWords辽宁福利彩票中心与第三方应用程序集成的简单示例。如果您有3rd party app,您希望我尝试一下,请在评论中留言。
谢谢,
拉斯
/********************************* * 特威里奥 Client Library * Based on the 特威里奥 REST API: //www.twilio.com/docs/api/rest * Version 1.0 * Created By: 拉斯 Savage * FreeAdWordsScripts.com *********************************/ function 特威里奥(accountSid, authToken) { this.ACCOUNT_SID = accountSid; this.AUTH_TOKEN = authToken; this.MESSAGES_ENDPOINT = '//api.twilio.com/2010-04-01/Accounts/'+this.ACCOUNT_SID+'/Messages.json'; this.CALLS_ENDPOINT = '//api.twilio.com/2010-04-01/Accounts/'+this.ACCOUNT_SID+'/Calls.json'; this.sendMessage = function(to,from,body) { var httpOptions = { method : 'POST', payload : { To: to, From: from, Body: body }, headers : getBasicAuth(this) }; var resp = UrlFetchApp.fetch(this.MESSAGES_ENDPOINT, httpOptions).getContentText(); return JSON.parse(resp)['sid']; } this.makeCall = function(to,from,whatToSay) { var url = 'http://proj.rjsavage.com/savageautomation/twilio_script/dynamicSay.php?alert='+encodeURIComponent(whatToSay); var httpOptions = { method : 'POST', payload : { To: to, From: from, Url: url }, headers : getBasicAuth(this) }; var resp = UrlFetchApp.fetch(this.CALLS_ENDPOINT, httpOptions).getContentText(); return JSON.parse(resp)['sid']; } function getBasicAuth(context) { return { 'Authorization': 'Basic ' + Utilities.base64Encode(context.ACCOUNT_SID+':'+context.AUTH_TOKEN) }; } }