Classic ASP Authentication


#1

Hi,

I have just started trying to get a simple Status update script (see below) working on our site. All it returns is ‘Could not authenticate you’

Can anyone please help steer me in the right direction?

strUrl = "https://api.twitter.com/1/statuses/update.json?include_entities=true HTTP/1.1"
Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP")
xmlHttp.Open "POST", strUrl, False
xmlHttp.setRequestHeader "Connection", "close"
xmlHttp.setRequestHeader "User-Agent", "OAuth gem v0.4.4"
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHttp.setRequestHeader "Authorization", "Oauth oauth_consumer_key=oauth_consumer_key"
xmlHttp.setRequestHeader "Authorization", "oauth_nonce=oauth_nonce"
xmlHttp.setRequestHeader "Authorization", "oauth_signature=oauth_signature"
xmlHttp.setRequestHeader "Authorization", "oauth_signature_method=HMAC-SHA1"
xmlHttp.setRequestHeader "Authorization", "oauth_timestamp=" & timestamp()
xmlHttp.setRequestHeader "Authorization", "oauth_token=oauth_token"
xmlHttp.setRequestHeader "Authorization", "oauth_version=1.0"
xmlHttp.setRequestHeader "Host", "api.twitter.com"
xmlHttp.Send "status=Hello%20Ladies%20%2b%20Gentlemen%2c%20a%20signed%20OAuth%20request%21"
postTransaction = xmlHttp.responseText
xmlHttp.abort()
set xmlHttp = Nothing 

Thanks
Matt
Oauth Virgin (as you can probably tell)


#2

oauth_token=6253282-eWudHldSbIaelX7swmsiHImEL4KinwaGloHANdrY&oauth_token_secret=2EEfA6BG3ly3sR3RjE0IBSnlQu4ZrUzPiYKmrkVU&user_id=6253282&


#3

Try this - works well but note the URLs may be outdated now Twitter API 1.1 has been introduced.

http://scottdesapio.com/VBScriptOAuth/


#4

The trusty old open source library ASPTwitter was recently updated to support Twitter API 1.1 with OAuth etc. This has the code you need and a working demo, in case it helps:

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

I tried ASPTwitter today and it works nicely with the current API. :slight_smile:


#5

Many thanks! This works like a champ.


#6

Cool. :slight_smile:


#7

The library was recently updated to work with 1.1, You can download the latest here: http://scottdesapio.com/VBScriptOAuth/