首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >coldfusion中推特oauth_signature生成中的问题

coldfusion中推特oauth_signature生成中的问题
EN

Stack Overflow用户
提问于 2019-11-20 06:14:10
回答 2查看 223关注 0票数 1

我在创建一个OAuth签名时启动了twitter测试,响应显示为

{“错误”:{“代码”:215,“消息”:“不良身份验证数据”}

添加了文档中提到的所有参数和标题,没有得到正确的结果,如果我做错了什么,请告诉我。

代码语言:javascript
复制
<cfset status = "Hello Ladies + Gentlemen, a signed OAuth">
<cfset include_entities = true >
<cfset oauth_consumer_key = "x3OgJNjJ5TPGj7jyvLz9rUzfU">
<cfset oauth_nonce = createUUID()>
<cfset oauth_signature_method ="HMAC-SHA1" >
<cfset oauth_timestamp   = GetTickCount()/1000>
<cfset oauth_token   = "1196333045885702145-BPWGfPyKakezuqYoLaYXiIgQ5TWAkf">
<cfset oauth_version   = "1.0">

<cfset parameterString = "include_entities=true&oauth_consumer_key=#oauth_consumer_key#&oauth_nonce=#oauth_nonce#&oauth_signature_method=#oauth_signature_method#&oauth_timestamp=#oauth_timestamp#&oauth_token=#oauth_token#&oauth_version=1.0&status=#urlEncodedFormat(status)#" >
<cfdump var="#parameterString#">

<cfhttp url="https://api.twitter.com/1.1/statuses/update.json" method="POST" >
  <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
  <cfhttpparam type="header" name="mimetype" value="application/x-www-form-urlencoded" />
  <cfhttpparam type="header" name="Accept" value="*/*" />
  <cfhttpparam type="header" name="Connection" value="close" />
  <cfhttpparam type="header" name="Host" value="api.twitter.com" />
  <cfhttpparam type="header" name="User-Agent" value="OAuth gem v0.4.4" />

  <cfhttpparam type="header" name="Content-Length" value="76">
  <cfhttpparam type="header" name="include_entities" value="#include_entities#">
  <cfhttpparam type="header" name="oauth_consumer_key" value="#oauth_consumer_key# ">
  <cfhttpparam type="header" name="oauth_nonce" value="#oauth_nonce#">
  <cfhttpparam type="header" name="oauth_signature_method" value="#oauth_signature_method#">
  <cfhttpparam type="header" name="oauth_timestamp" value="#oauth_timestamp#">
  <cfhttpparam type="header" name="oauth_token" value="#oauth_token#">
  <cfhttpparam type="header" name="oauth_version" value="#oauth_version#">
  <cfhttpparam type="header" name="status" value="#urlEncodedFormat(status)#">

 <cfhttpparam type="body" value="#parameterString#"   >
</cfhttp>
<cfdump var="#cfhttp#"><cfabort>
EN

回答 2

Stack Overflow用户

发布于 2019-11-21 07:53:29

使用此方法,它将正确工作。

代码语言:javascript
复制
<cfset consumerKey = "xxxxxxxxxxxxxx">
    <cfset consumerSecret = "xxxxxxxxxxxxxxxxxxx">
    <cfset bearerToken = ToBase64(consumerKey & ":" & consumerSecret)>
    <cfset authorization = "Basic " & bearerToken>
    <cfhttp url="https://api.twitter.com/oauth2/token" method="post" charset="utf-8" >
        <cfhttpparam type="header" name="Authorization" value="#authorization#">
        <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded;charset=UTF-8">
        <cfhttpparam type="body" value="grant_type=client_credentials">
    </cfhttp>
票数 2
EN

Stack Overflow用户

发布于 2019-11-21 09:42:49

引用此命令并在twitter上创建您的开发人员帐户,通过您自己的密钥,work.refer将此为oauth创建密钥

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58947860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档