Twitter、oauth和coldfusion

Twitter、oauth和coldfusion,coldfusion,twitter,oauth,Coldfusion,Twitter,Oauth,我正试图在推特上发帖。我已经验证了应用程序,现在想发布更新 以下是我的http帖子: <cfhttp url="http://api.twitter.com/1/statuses/update.json" method="post"> <cfhttpparam type="header" name="status" value="#urlEncodedFormat('my test post')#" /> <cfhttpparam type="header" n

我正试图在推特上发帖。我已经验证了应用程序,现在想发布更新

以下是我的http帖子:

<cfhttp url="http://api.twitter.com/1/statuses/update.json" method="post">
 <cfhttpparam type="header" name="status" value="#urlEncodedFormat('my test post')#" />
 <cfhttpparam type="header" name="oauth_consumer_key" value="xxx" />
 <cfhttpparam type="header" name="oauth_nonce" value="xxx" />
 <cfhttpparam type="header" name="oauth_signature_method" value="#urlEncodedFormat('HMAC-SHA1')#" />
 <cfhttpparam type="header" name="oauth_token" value="xxx" />
 <cfhttpparam type="header" name="oauth_timestamp" value="#GetTickCount()#" />
 <cfhttpparam type="header" name="oauth_version" value="1.0" />
</cfhttp>

有人这样做过吗?我走的路对吗?

你读过这个吗

您需要构造“签名基字符串”并作为主体发布(警告:未测试的代码,用于CF8+)


-



GetTickCount()以毫秒为单位返回,api以秒为单位返回,所以不要忘记div 1000。有人编写了一个CFC用于Twitter。你看过吗?Andy,不是提供一个解决方案,而是一个观察:您上面的代码显示了#urlEncodedFormat('HMAC-SHA1')#的使用,但这似乎表明存在误解。该函数的arg是要格式化的URL,虽然需要第二个参数来指示charest,但这不是有效的参数。希望其他可能的解决方案也能有所帮助。你解决过问题吗?
<cffunction name="makeSignatureBaseString" returntype="string" output="false">
  <cfargument name="httpMethod" type="string" required="true">
  <cfargument name="baseUri" type="string" required="true">
  <cfargument name="values" type="struct" required="true">

  <cfset var signatureBaseString = "#httpMethod#&#URLEncodedFormat(baseUri)#&">
  <cfset var keys = StructKeyArray(values)>
  <cfset var key = "">

  <cfset ArraySort(keys, "textNoCase")>
  <cfloop array="#keys#" index="key">
    <cfset signatureBaseString &= URLEncodedFormat("&#key#=#values[key]#")>
  </cfloop>

  <cfreturn signatureBaseString>
</cffunction>
<!--- using values from http://dev.twitter.com/pages/auth#auth-request --->
<cfset params = {
  oauth_consumer_key = "GDdmIQH6jhtmLUypg82gる",
  oauth_nonce = "oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y",
  oauth_signature_method = "HMAC-SHA1",
  oauth_token = "819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw",
  oauth_timestamp = "1272325550",
  oauth_version = "1.0"
}>

<cfhttp url="http://api.twitter.com/1/statuses/update.json" method="POST">
 <cfloop collection="#params#" item="key">
   <cfheader type="header" name="#key#" value="#params[key]#">
 </cfloop>

 <!--- add status to the params for makeSignatureBaseString() --->
 <cfset params.status = "setting up my twitter 私のさえずりを設定する">

 <cfhttpparam type="body"
   value="#makeSignatureBaseString('POST', 'http://api.twitter.com/1/statuses/update.json', params)#">
</cfhttp>