在 twilio 中发送 SMS 返回 21603:需要“发件人"号码 [英] Sending SMS in twilio returns 21603 : A 'From' number is required

查看:22
本文介绍了在 twilio 中发送 SMS 返回 21603:需要“发件人"号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个常规资金账户 - 它会坚持没有 From Number - 我也尝试过作为请求参数而不是请求正文,SID 和 TOKEN 是正确的,通过修改它们并得到适当的错误进行测试.适用于 twilio 库,而不是作为独立的 POST

This is a regular funded account - It will insist there is no From Number - I also tried as request parameters rather than request body, SID and TOKEN are correct, tested by modifying them and getting appropriate error. Works fine with the twilio libraries, not as a standalone POST

POST /2010-04-01/Accounts/ACCOUNT_SID/Messages.json HTTP/1.1
Host: ACCOUNT_SID:AUTH_TOKEN@api.twilio.com
Content-Type: text/json
Cache-Control: no-cache

{ "body": "Jenny please?! I love you <3", "From": VALID_TWILIO_NUMBER, "to": MY_CELL }

我还想将 ACCOUNT_SID 和 AUTH_TOKEN 指定为标头参数,但 Twilio 无法识别它们.

Also I would like to specify the ACCOUNT_SID and AUTH_TOKEN as header parameters, but Twilio does not recognize them.

推荐答案

以下作品(来自 POSTMAN 历史)

The following works (from POSTMAN history)

POST /2010-04-01/Accounts/ACCOUND_SID/Messages.json HTTP/1.1
Host: api.twilio.com
Authorization: Basic Base64_encoding(ACCOUNT_SID:AUTH_TOKEN)
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

Body=%22Test+1+-+urlencoded%22&From=%22%2BVALID_TWILIO_NUMBER%22&To=%22%2BMY_CELL%22

一些观察:这在 Chrome 中使用 POSTMAN 和在 Firefox 中使用 HTTPRequester 工作(通过用户/密码对话框交互输入授权)

A few observations: This worked using POSTMAN in Chrome and HTTPRequester in Firefox (Authorization entered interactively through user/passwd dialog)

Body、From 和 To 参数必须这样拼写,​​如果第一个字母是小写,则会返回上述错误或类似错误.

The Body, From, and To parameters MUST be spelled that way, if the first letter is lowercase, it will return the above error or similar.

这是唯一有效的 Content-Type - 无法让它与 JSON 请求正文一起使用(我在原始问题上提出的方式) - 这仍然是一个悬而未决的问题.

That was the only Content-Type that worked - could not get it to work with a JSON request body (the way I posed it on the original question) - that remains an open issue.

这篇关于在 twilio 中发送 SMS 返回 21603:需要“发件人"号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆