2012-04-18 29 views
0

我目前正在使用twitcurl在Linux和Twitter上使用C++。我已經構建了twitcurl,它似乎一般工作,我已經能夠從他們的項目中稍微定製的twitterClient示例版本發佈推文。不過,我一直在努力閱讀用戶的時間表。從twitcurl獲取未授權的錯誤timelineUserGet方法

現在,我知道一般身份驗證正在發揮作用,因爲我設法以正確的用戶身份發起推文。

然而,當我嘗試使用下面的代碼來讀取用戶的時間表:

/* 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生成多個?可能與認證衝突的符號。

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

回答

1

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?

+2

你應該張貼一些鏈接的內容。如果鏈接服務器失敗,那麼這對其他用戶不會有幫助。 – Taryn 2012-07-05 11:37:06

+0

@bluefeet他實際上是這樣做的,他的文章內容是鏈接的實際解決方案。 – ForceMagic 2012-10-10 18:56:55

+1

@ForceMagic我的觀點是,鏈接的全部內容應該在這裏發佈,在鏈接失敗的情況下,沒有什麼可引用的。 – Taryn 2012-10-10 19:01:08