Alamofire要求twilio迅速

编程入门 行业动态 更新时间:2024-10-17 02:50:34
本文介绍了Alamofire要求twilio迅速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试从twilio收到一条短信,但回复为零。有人可以说我在做什么错吗?

I'm trying to get an SMS from twilio but get nil in response. Can anyone say what I'm doing wrong?

class SMSVerificationService: NSObject { static let sharedInstance = SMSVerificationService() func SMSRequest(countryCode:String, phoneNumber: String) { let accountSid = "ACc4d9785419f144412823ff20as34660c3d" let authToken = "4wqecx41f8999caa23735da214" // changed :) let url = URL(string: "\(accountSid):\(authToken)@api.twilio/2010-04-01/Accounts\(accountSid)/Messages") print("url", url!) let parameters = [ "To": "+37378847884", "From" : "+14243960339", "Body": "Hi daddy" ] Alamofire.request(url!, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: [:]).responseJSON { response in let response = String(describing: response.result.value) print(response) } } }

推荐答案

此处是Twilio开发人员的传播者。

Twilio developer evangelist here.

我们不建议您向Twilio API发出请求直接从您的本机应用程序。为此,您需要在某处的应用程序中存储或检索帐户SID和身份验证令牌。如果这样做,那么恶意攻击者可能会访问您的凭据并滥用您的Twilio帐户。

We do not recommend that you make requests to the Twilio API directly from your native application. To do so, you would need to store or retrieve your account SID and auth token in the application somewhere. If you do this, then a malicious attacker could get access to your credentials and abuse your Twilio account.

这实际上称为窃听者漏洞,并于今年初撰写。。

相反,我们建议您创建一个Web应用程序并从那里发送API请求。这里有一篇有关如何执行此操作的博客文章:> www.twilio/blog/2016/11/how-to-send-an-sms-from-ios-in-swift.html

Instead we recommend that you create a web application and send the API requests from there. There is a blog post on how to do that here: www.twilio/blog/2016/11/how-to-send-an-sms-from-ios-in-swift.html

我注意到您的课程也称为 SMSVerificationService 。如果您想建立电话验证,那么我建议您看一下 Twilio验证API 可以为您完成很多工作。

I notice that your class is called SMSVerificationService too. If you are looking to build phone verification, then I recommend you take a look at the Twilio Verify API that does a lot of the work for you.

更多推荐

Alamofire要求twilio迅速

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

发布评论

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

>www.elefans.com

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