ColdFusion发布到Twitter身份验证错误 [英] ColdFusion Post To Twitter Authentication Error

查看:173
本文介绍了ColdFusion发布到Twitter身份验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我的项目需要我自己的模块,所以我不能使用各种包和产品。尽管如此,使用正确的令牌consumer_key,consumer_secret和token_secret变量,创建正确的基本签名字符串,从而从该字符串的OAuth签名,我没有问题通过我的ColdFusion模块抓取Twitter数据。如果他们中的任何一个关闭,我将无法获得Twitter数据。

First off, my project requires me to make my own module so I can't use the various packages and products out there. Having said that, using the correct token, consumer_key, consumer_secret and token_secret variables, creating the correct Base Signature String and thus OAuth Signature from that string, I have had NO problem grabbing Twitter data via my ColdFusion module. If either of them were off, I wouldn't be able to even get Twitter data.

所以知道我的变量是正确的,我仍然不能POST一个简单状态通过ColdFusion推送到我的Twitter帐户。每次我尝试我得到相同的错误:代码:32,消息:'无法验证你'。因为我知道它不能是变量,它必须是如何通过ColdFusion发送POST,但我不确定我做错了什么。以下是我用来提交POST的代码:

So knowing that my variables are correct, I am still unable to POST a simple status tweet to my Twitter account via ColdFusion. Each time I try I get the same error: "Code:32, Message:'Could not authenticate you'". Since I know it can't be the variables, it has got to be how I'm sending the POST via ColdFusion, but I am unsure of what I am doing wrong. The following is the code I use to submit the POST:

<cfhttp url="https://api.twitter.com/1.1/statuses/update.json" method="POST" throwonerror="yes" >
    <cfhttpparam type="header" name="Authorization" value='OAuth oauth_consumer_key="#oauthStruct.oauth_consumer_key#", oauth_nonce="#oauthStruct.oauth_nonce#", oauth_signature="#oauthStruct.oauth_signature#", oauth_signature_method="#oauthStruct.oauth_signature_method#", oauth_timestamp="#oauthStruct.oauth_timestamp#", oauth_token="#oauthStruct.oauth_token#", oauth_version="#oauthStruct.oauth_version#"'>
    <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
    <cfhttpparam type="formfield" name="status" value="#oauthStruct.status#">
</cfhttp>

有人可以看看上面的代码,帮助我弄清楚如果我遗漏了什么或提交不正确的这个电话?

Can somebody please look over the above code and help me figure out if I'm missing something or submitting incorrectly this call?

更新:我将上述代码更改为:

Update: I changed the above code to this:

    <cfhttp url="https://api.twitter.com/1.1/statuses/update.json" method="POST" throwonerror="yes" >
        <cfhttpparam type="header" name="Authorization" value='OAuth oauth_consumer_key="#oauthStruct.oauth_consumer_key#", oauth_nonce="#oauthStruct.oauth_nonce#", oauth_signature="#oauthStruct.oauth_signature#", oauth_signature_method="#oauthStruct.oauth_signature_method#", oauth_timestamp="#oauthStruct.oauth_timestamp#", oauth_token="#oauthStruct.oauth_token#", oauth_version="#oauthStruct.oauth_version#"'>
        <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
        <cfhttpparam type="header" name="oauth_consumer_key" value="#oauthStruct.oauth_consumer_key#">
        <cfhttpparam type="header" name="oauth_nonce" value="#oauthStruct.oauth_nonce#">
        <cfhttpparam type="header" name="oauth_signature" value="#oauthStruct.oauth_signature#">
        <cfhttpparam type="header" name="oauth_signature_method" value="#oauthStruct.oauth_signature_method#">
        <cfhttpparam type="header" name="oauth_timestamp" value="#oauthStruct.oauth_timestamp#">
        <cfhttpparam type="header" name="oauth_token" value="#oauthStruct.oauth_token#">
        <cfhttpparam type="header" name="oauth_version" value="#oauthStruct.oauth_version#">
        <cfhttpparam type="body" value="#signature_string#">
    </cfhttp>

它仍然不工作,同样的验证错误。任何其他想法?

It still does not work, same authenticate error. Any other ideas?

推荐答案

我想出来。所以其他人可以理解这个过程如何,与新的API(1.1),这是如何发布状态更新到您的Twitter帐户:

I figured it out. So that others can understand how this process goes, with the new API (1.1), this is how you post a status update to your Twitter account:

    <cfhttp url="https://api.twitter.com/1.1/statuses/update.json" method="POST" throwonerror="yes" >
        <cfhttpparam type="header" name="Authorization" value='OAuth oauth_consumer_key="#oauthStruct.oauth_consumer_key#", oauth_nonce="#oauthStruct.oauth_nonce#", oauth_signature="#oauthStruct.oauth_signature#", oauth_signature_method="#oauthStruct.oauth_signature_method#", oauth_timestamp="#oauthStruct.oauth_timestamp#", oauth_token="#oauthStruct.oauth_token#", oauth_version="#oauthStruct.oauth_version#"'>
        <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
        <cfhttpparam type="body" value="status=#oauthStruct.status#">
    </cfhttp>

如果我没有Authorization标头参数,我最终出现400错误请求错误。您将所有必要的OAuth参数(包括您的数字签名)放在逗号分隔的列表中,如上所示,指明您的内容类型,最重要的是,您提供了一个URL查询字符串您的cfhttp调用的主体参数中的剩余变量。

If I did not have the Authorization header parameter, I ended up with a 400 Bad Request error. You put all the necessary OAuth parameters, including your digital signature, in a comma delimited list as shown above, indicate your content-type, and most importantly, you provide as a URL Query String the remaining variables in the body parameter of your cfhttp call.

这篇关于ColdFusion发布到Twitter身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆