问题
I am trying to implement twitter posting on a website. when a user posts an alert and they check off "submit to twitter" I want to send the contents of the box (140 chars of it) to the associated twitter account. So I've done the following:
- Registered a new app in twitter
- Gotten all of my tokens/keys
- Set up the following library: http://scottdesapio.com
- Changed all of the parameters per the instructions
Every time I try to submit, though, I'm getting an "Could not authenticate with OAuth" error. I'm trying to do this all in one go, so I'm not grabbing the token from twitter but filling in both the oauth_token and the oauth_token_secret in my request, but still nothing. Has anyone had success with doing something like this in classic ASP?
Code:
Dim objOAuth : Set objOAuth = New cLibOAuth
objOAuth.ConsumerKey = twitter_consumer_key
objOAuth.ConsumerSecret = twitter_consumer_secret
objOAuth.EndPoint = "http://twitter.com/statuses/update.json"
objOAuth.Host = "api.twitter.com"
objOAuth.RequestMethod = "POST"
objOAuth.UserAgent = "Alert System Updater"
objOAuth.Parameters.Add "oauth_token", twitter_oauth_token
objOAuth.Parameters.Add "oauth_token_secret", twitter_oauth_secret
objOAuth.Parameters.Add "status", tstatus
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
来源:https://stackoverflow.com/questions/15905921/submitting-to-twitter-with-classic-asp