开发者

Does twilio-csharp work in Mono?

开发者 https://www.devze.com 2023-04-09 04:12 出处:网络
Hello I\'ve recently been messing around with Twilio and their official twilio-csharp library. I\'m using it on mono 2.10.5(x86-64) on Linux and I\'m having problems getting a basic example working.

Hello I've recently been messing around with Twilio and their official twilio-csharp library. I'm using it on mono 2.10.5(x86-64) on Linux and I'm having problems getting a basic example working.

My code:

var twilio = new TwilioRestClient("[accountsid]", "[authkey]");
var msg = twilio.SendSmsMessage("+1316313XXXX, "+1918917XXXX", "I'm a monkey Mr. Anderson");

Seems to be very simple b开发者_JS百科ut when running it, the msg object returned is null and no message gets sent. Is this something I'm doing wrong or does the library not work in Mono?


The problem is detailed in this page: http://www.mono-project.com/UsingTrustedRootsRespectfully

Basically, Mono doesn't ship with any root certificate authorities. So, the quick and dirty fix is to trust all certificates:

ServicePointManager.ServerCertificateValidationCallback = 
                delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
                    { return true; };

It's not very secure, but depending on your uses, it may not matter.


In case it's helpful for anyone else that come across this question, I added monotouch/for android projects to this fork of twilio-csharp:

https://github.com/joelmartinez/twilio-csharp

pull request to fold the changes into the main project is pending as of the writing of this answer :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号