问题
I have a twitter application which sends tweets automatically for uses of our blog application whenever they post a new blog item.
This application is now returning an error
HTTP/1.1 401 Unauthorized Content-Type: application/json; charset=utf-8 Date: Mon, 12 Nov 2012 22:05:27 UTC Server: tfe
{"errors":[{"message":"Could not authenticate you","code":32}]}
My coldfusion code is as follows for posting the tweet:
<cfset var tweetURL = "https://api.twitter.com/1.1/statuses/update.json">
<cfhttp url="#tweetURL#" method="post" result="result">
<cfhttpparam type="header" name="Authorization" value="#oauth.header#" encoded="no">
<cfhttpparam type="formfield" name="status" value="#tweet#" encoded="no">
</cfhttp>
I have dumped out all the oauth header values, they are all as they should be, they are not returning any errors at all. its only the status update that is returning the unauthorized error.
What other things do I need to check? I thought my app may have been blocked or something but its all up and working. I've tested the user accounts they have authorized the app.
回答1:
I worked it out. I was to busy validating the input of the header and auth tokens etc that I overlooked the status. It wasn't urlencoded. although this apparently worked in the old version. it didn't pass for the new.
来源:https://stackoverflow.com/questions/13352433/twitter-api-status-update-not-working-when-updating-to-v1-1