I get great performance in the request_token call.
I've racked my brain trying to come up with a way to send the same
oauth headers some other way (other than writing a php page or
something to do the same). I'm using .Net 1.1 standard HTTPWebRequest
methods to do this. I would expect them to detect the response
correctly.
If I can't figure some other way out of it, I'll have to try writing a
little curl request. I'm sure there's something wrong with the way
I'm doing things, but I just can't see it. The weird part is that if
there were something wrong with my oauth headers or signature or
something, I'd expect the page to return with an error, the timeout is
the unexpected part.
In case it helps, here's my oauth request method:
--
Public Shared Function GenerateOauthRequest(ByVal RequestUrl As
String, ByVal RequestMethod As String, ByVal ConsumerKey As String,
ByVal ConsumerSecret As String, ByVal OauthToken As String, ByVal
OauthTokenSecret As String, Optional ByVal IncludeOauthToken As
Boolean = False, Optional ByVal Data As String = Nothing, Optional
ByVal OauthVerifier As String = "", Optional ByVal OauthCallback As
String = "") As Hashtable
Dim objRequest As HttpWebRequest
Dim datNow As DateTime = Date.UtcNow
Dim lngTimestamp As Long = DateToUnixTimestamp(datNow)
Dim strNonce As String = IntegerToSerialNumber(lngTimestamp) &
GenerateToken(20)
Dim strSignatureMethod As String = "HMAC-SHA1"
Dim strHMACKey As String = ConsumerSecret & "&" & OauthTokenSecret
Dim stbSignature As New StringBuilder
Dim strSignature As String = ""
stbSignature.Append(RequestMethod)
stbSignature.Append("&")
stbSignature.Append(UrlEncodeRFC(RequestUrl))
Dim stbOAuthData As New StringBuilder
If RequestMethod = "GET" And Not IsNothing(Data) Then
If Data.Length > 0 Then
stbOAuthData.Append(Data)
stbOAuthData.Append("&")
End If
End If
stbOAuthData.Append("oauth_consumer_key=")
stbOAuthData.Append(ConsumerKey)
stbOAuthData.Append("&oauth_nonce=")
stbOAuthData.Append(strNonce)
stbOAuthData.Append("&oauth_signature_method=")
stbOAuthData.Append(strSignatureMethod)
stbOAuthData.Append("&oauth_timestamp=")
stbOAuthData.Append(lngTimestamp)
If IncludeOauthToken And Not IsNothing(OauthToken) Then
If OauthToken.Length > 0 Then
stbOAuthData.Append("&oauth_token=")
stbOAuthData.Append(OauthToken)
End If
End If
If OauthVerifier.Length > 0 Then
stbOAuthData.Append("&oauth_verifier=")
stbOAuthData.Append(OauthVerifier)
End If
stbOAuthData.Append("&oauth_version=1.0")
stbSignature.Append("&")
stbSignature.Append(UrlEncodeRFC(stbOAuthData.ToString))
strSignature = stbSignature.ToString
Dim objHMAC As New HMACSHA1(Encoding.ASCII.GetBytes(strHMACKey))
Dim bytMessage() As Byte = Encoding.ASCII.GetBytes(strSignature)
Dim bytSignature() As Byte = objHMAC.ComputeHash(bytMessage)
strSignature = Convert.ToBase64String(bytSignature)
If RequestMethod = "GET" And Not IsNothing(Data) Then
If Data.Length > 0 Then RequestUrl &= "?" & Data
End If
objRequest = WebRequest.Create(RequestUrl)
objRequest.Timeout = 3
objRequest.Method = RequestMethod
Dim stbAuthorizationHeader As New StringBuilder
stbAuthorizationHeader.Append("OAuth realm=""" & RequestUrl &
)
stbAuthorizationHeader.Append(",oauth_consumer_key=""" &
ConsumerKey & )
stbAuthorizationHeader.Append(",oauth_nonce=""" & strNonce & )
stbAuthorizationHeader.Append(",oauth_signature=""" &
UrlEncodeRFC(strSignature) & )
stbAuthorizationHeader.Append(",oauth_signature_method=""" &
strSignatureMethod & )
stbAuthorizationHeader.Append(",oauth_timestamp=""" & lngTimestamp
& )
If IncludeOauthToken And Not IsNothing(OauthToken) Then
If OauthToken.Length > 0 Then
stbAuthorizationHeader.Append(",oauth_token=""" &
UrlEncodeRFC(OauthToken) & )
End If
End If
If OauthVerifier.Length > 0 Then
stbAuthorizationHeader.Append(",oauth_verifier=""" &
UrlEncodeRFC(OauthVerifier) & )
End If
stbAuthorizationHeader.Append(",oauth_version=""1.0""")
objRequest.Headers.Add("Authorization",
stbAuthorizationHeader.ToString)
Dim hshReturn As New Hashtable
Dim objResponse As HttpWebResponse
Dim objReader As StreamReader
hshReturn.Add("success", False)
Try
If RequestMethod = "POST" And Not IsNothing(Data) Then
objRequest.ContentLength = Data.Length
Dim objWriter As New StreamWriter(objRequest.GetRequestStream)
objWriter.Write(Data.ToString)
objWriter.Close()
End If
objResponse = objRequest.GetResponse
If Not IsNothing(objResponse.Headers("Content-Location")) Then
hshReturn.Add("content_location", objResponse.Headers("Content-
Location"))
objReader = New StreamReader(objResponse.