Classic ASP Issue - Could not authenticate you Code 32


#1

Does anyone have any idea why the code below throws up an error 32 on the Twitter 1.1 API?

I don’t profess to understand twitters API’s very well, my skills lie elsewhere, but would really love to work out what is wrong with this.

<%
Dim objOAuth : Set objOAuth = New cLibOAuth
objOAuth.ConsumerKey = "XXXXXX"
objOAuth.ConsumerSecret = "XXXXXX"
objOAuth.EndPoint = "https://api.twitter.com/1.1/statuses/update.json"
objOAuth.Host = "api.twitter.com"
objOAuth.RequestMethod = "POST"
objOAuth.UserAgent = "OAuth gem v0.4.4"
objOAuth.Parameters.Add “oauth_token”, "XXXXXXX"
objOAuth.Parameters.Add “oauth_token_secret”, "XXXXXX"
objOAuth.Parameters.Add “status”, Server.URLEncode(“This is a test Message”)
objOAuth.Send()

Dim strResponseText : strResponseText = objOAuth.ResponseText
Dim strErrorCode : strErrorCode = objOAuth.ErrorCode

If Not IsNull(strErrorCode) Then
Response.Status = RESPONSE_STATUS_500
Response.Write strErrorCode
Else
Response.ContentType = "text/html"
Response.CharSet = "utf-8"
Response.Write strResponseText
End If

%>

If I change the code to post to V1, I get the following back

{“error”:“Could not authenticate with OAuth.”,“request”:"/1/statuses/update.json?oauth_consumer_key=XXXXXX&oauth_nonce=1432948037&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1369586161&oauth_token=XXXXXX&oauth_token_secret=XXXXXX&oauth_version=1.0&status=This%2Bis%2Ba%2Btest%2BMessage&oauth_signature=6UiRckJoMfsA86wwQE8%2FWAJ8k3Y%3D"}


#2

Your code is almost there, you just need to use Twitter’s OAuth authentication model.

Feel free to use my ASPTwitter class as a starting point. The code already does OAuth authentication and gets tweets, and works with Twitter API 1.1. Just copy the token method and change the API URL and post data:

http://www.timacheson.com/Blog/2013/jun/asptwitter


#3

Confirming @timacheson’s response, error code 32 corresponds to an HTTP response code of 401 Unauthorized. There is probably a bug in your library’s implementation of OAuth signing. You will want to validate the results of your library’s signing procedure against a library known to be working. Good luck!


#4

テスト


#5

test


#6

@timacheson just tried your scripts, and they work great, thank you! One snag though, it stops working if you try to tweet something which a SPACE in it. It throws up the same error

{“errors”:[{“message”:“Could not authenticate you”,“code”:32}]}

Been throw the scripts, and tried to server.urlencode the Request.Form(“Status”), however no joy :frowning: