c++ - 从 twitcurl timelineUserGet 方法获取未授权错误

标签 c++ twitter twitter-oauth

我目前正在使用 twitcurl 在 Linux 和 Twitter 上使用 C++。我已经构建了 twitcurl,它似乎可以正常工作,我已经能够从他们项目中的 twitterClient 示例的稍微定制的版本中发推文。但是,我一直在努力阅读用户的时间表。

现在,我知道通用身份验证正在工作,因为我设法首先以正确的用户身份发送推文。

但是,当我尝试使用以下代码读取用户时间线时:

/* Get user timeline */
replyMsg = "";
printf( "\nGetting user timeline\n" );
if( twitterObj.timelineUserGet( true, false, 5 ) )
{
    twitterObj.getLastWebResponse( replyMsg );
    printf( "\ntwitterClient:: twitCurl::timelineUserGet web response:\n%s\n", replyMsg.c_str() );
}
else
{
    twitterObj.getLastCurlError( replyMsg );
    printf( "\ntwitterClient:: twitCurl::timelineUserGet error:\n%s\n", replyMsg.c_str() );
}

我收到以下错误:

twitterClient:: twitCurl::timelineUserGet web response:
<?xml version="1.0" encoding="UTF-8"?><hash><request>/1/statuses/user_timeline.xml?     count=5?trim_user=1</request><error>Not authorized</error></hash>

我不确定这是否与 twitcurl 使用 multiple 生成的无效 url 有关?可能与身份验证冲突的符号。

完整的源代码可以在 https://github.com/paulspencerwilliams/CPlusPlusSocialPlayground/blob/master/twitterClient.cpp 找到.

最佳答案

The following post helped me to solve the same problem

What steps will reproduce the problem?

Sending certain characters to twitter API (Any character that has to be percent encoding, except the blank space?).

What is the expected output? What do you see instead?

I'd expect twitter's server to accept my oauth signature but it hits me in the face instead.

What version of the product are you using? On what operating system?

r88, this problem applies to both linux and wii (through devkitpro)

Please provide any additional information below.

The problem can be fixed by removing the urlencode() calls within buildOAuthRawDataKeyValPairs() in oauth.cpp.

That is according to how twitter says we have to do it. I don't know (did not check) if that's how the oauth spec says it should be done but it is clearly how it works with twitter.

Did you write oauthlib.cpp?

关于c++ - 从 twitcurl timelineUserGet 方法获取未授权错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10214279/

相关文章:

c# - 如何在 C# 中使用 VerQueryValue 函数获取构建日期?

c++ - 如何在 Vulkan 中获取下一帧呈现时间

iphone - 如何使用 SA_OAuthTwitterEngine 在没有 PIN 的情况下从 iPhone 发布推文?

c++ - 来自 dev cpp 文件的标准输入

c# - 使用 Windows AES 加密提供程序在 C++ 中解密 C# 加密的数据

ruby-on-rails - Twitter::Error::ServiceUnavailable(容量过大)

php - Twitter API 在调用 statuses/update.json 时响应 "Your credentials do not allow access to this resource"

python - 如何获取使用 tweepy 库的 update_status 方法生成的推文的推文 ID

twitter-oauth - Twitter REST API - 如何检查应用程序是否具有特定权限?

.net - Owin Twitter 登录 - 根据验证程序,远程证书无效