如何使用Mono获取twitter user_timeline?

时间:2013-11-08 13:23:12

标签: c# twitter mono

我使用Bobby's answer来获取Twitter的用户时间线,代码很容易理解,而且我在Windows / .NET 4.5下尝试过,它运行得很好。

但是当我尝试使用完全相同的代码在Ubuntu / Mono 2.10上运行时,它会引发异常:

System.Net.WebException has been thrown
Error getting response stream (Write: The authentication or decryption has failed.): SendFailur

似乎Mono无法在http请求中添加OAuth标头,那么使用Mono获取Twitter用户时间线有什么好方法吗?

这是StackTrace:

System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.Exception: The authentication or decryption has failed. ---> System.Exception: Invalid certificate received from server. Error code: 0xffffffff800b010a
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0
  at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
  at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
  at test1.MainClass.Main (System.String[] args) [0x00207] in /home/jerry/test1/test1/Main.cs:89

1 个答案:

答案 0 :(得分:0)

好的,这是我的最终解决方案,导入SSL证书:

mozroots --import --ask-remove

它解决了我的问题。