Sub EncodeTwitterConsumerKeyAndSecret(Key As String, Secret As String)
Dim STRutils As StringUtils , BYTutils As ByteConverter ,tempstr As String
tempstr = STRutils.EncodeUrl(Key, "UTF8") & ":" & STRutils.EncodeUrl(Secret, "UTF8")
TwitterEncodedKey = STRutils.EncodeBase64( BYTutils.StringToBytes(tempstr, "UTF8"))
End Sub
'What I have so far:
HttpUtils.PostString("Twitter", "https://api.twitter.com/oauth2/token", "Authorization=Basic " & TwitterEncodedKey & "&Content-Type=application/x-www-form-urlencoded;charset=UTF-8")
Why are you using HttpUtils instead of HttpUtils2?
Immediately after sending the request you should call Job.GetRequest.SetHeader to set the two headers.
Sub GetTwitterAccessCode(Job As HttpJob, TargetModule As Object)
'Dim SSL As SocketSSL
'SSL.Initialize("SSL")
'SSL.Connect("api.twitter.com", 443, 20)
Dim tempstr As StringBuilder , BYTutils As ByteConverter
tempstr.Initialize
tempstr.Append("User-Agent: LCARS UI\r\n")
tempstr.Append("Authorization: Basic " & TwitterEncodedKey & "\r\n")
tempstr.Append("Content-Type: application/x-www-form-urlencoded;charset=UTF-8\r\n")
tempstr.Append("Content-Length: 29\r\n")
tempstr.Append("Accept-Encoding: gzip\r\n")
tempstr.Append("\r\n")
tempstr.Append("grant_type=client_credentials")
Job.Initialize("Twitter", TargetModule)
Job.GetRequest.InitializePost2("https://api.twitter.com/oauth2/token", BYTutils.StringToBytes(tempstr.ToString, "UTF8") )
End Sub
Sub GetTwitterAccessCode(Job As HttpJob, TargetModule As Object)
'Dim SSL As SocketSSL
'SSL.Initialize("SSL")
'SSL.Connect("api.twitter.com", 443, 20)
Dim tempstr As StringBuilder , BYTutils As ByteConverter
tempstr.Initialize
tempstr.Append("User-Agent: LCARS UI" & CRLF)
tempstr.Append("Authorization: Basic " & TwitterEncodedKey & CRLF)
tempstr.Append("Content-Type: application/x-www-form-urlencoded;charset=UTF-8" & CRLF)
tempstr.Append("Content-Length: 29" & CRLF)
tempstr.Append("Accept-Encoding: text/plain" & CRLF)
tempstr.Append(CRLF)
tempstr.Append("grant_type=client_credentials")
Job.Initialize("Twitter", TargetModule)
Job.PostString("https://api.twitter.com/oauth2/token", "User-Agent=LCARS UI")
Log(tempstr.ToString)
Job.GetRequest.InitializePost2("https://api.twitter.com/oauth2/token", BYTutils.StringToBytes(tempstr.ToString, "UTF8") )
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?