twilio获取消息详细信息(方法不允许)

时间:2013-07-02 14:41:33

标签: javascript twilio

 url = 'https://api.twilio.com/2010-04-01/Accounts/'+ACCOUNT_SID+'/SMS/Messages/'+Sid+'.json';

 var payLoadData = {
          'SMSMessageSid' : Sid
        };
 var options =
      {
        method : "GET",
        payload : payLoadData,
        headers : {
          'Authorization' : 'Basic ' + Utilities.base64Encode(ACCOUNT_SID + ':' + ACCOUNT_TOKEN)
        }
      };

  var response = UrlFetchApp.fetch(url, options);

为什么使用此google_script会提供Method_Not_Allowed

Request failed for https://api.twilio.com/2010-04-01/Accounts/XXXXXXXXXXXXX/SMS/Messages/XXXXXXXXXXXXXXXXXXXXX.json returned code 405. Server response: {"status":405,"message":"Method not allowed","code":20004,"more_info":"http:\/\/www.twilio.com\/docs\/errors\/20004"} (line 374, file "MakePhoneCall")

我们可以看到,https://www.twilio.com/user/account/developer-tools/api-explorer#GET/2010-04-01/Accounts/[AccountSid]/SMS/Messages/[SMSMessageSid ] [格式]

它是根据这个api ref构建的

1 个答案:

答案 0 :(得分:0)

使用GET方法时似乎不应使用有效负载,因此使用params可以解决问题。

但是,同样的方法在获取调用的详细信息时有效,但在消息中却没有,有趣的是:)