我使用Bobby 的答案来获取 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 无法将 OAuth 标头添加到 http 请求中,那么有没有什么好的方法可以使用 Mono 获取 twitter 用户时间线?
这是堆栈跟踪:
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