Commit c935bc88 authored by Mehrdad Momeny's avatar Mehrdad Momeny
Browse files

Fetching list of twitter Lists that the requested user owns, fixed!

The trick here was that You should pass the base URL to TwitterApiMicroBlog::authorizationHeader() funtion to make OAuth signature based on that! (without parameters!)
CCBUG:264091
CCMAIL:daniel.kreuter85@gmail.com
parent 28e1b45d
......@@ -83,6 +83,7 @@ void TwitterListDialog::slotButtonClicked(int button)
KMessageBox::error(this, i18n("You should provide both list author username and list name."));
} else {
blog->addListTimeline(account, ui.username->text(), ui.listname->text());
accept();
}
} else
KDialog::slotButtonClicked(button);
......
......@@ -247,15 +247,19 @@ void TwitterMicroBlog::fetchUserLists(TwitterAccount* theAccount, const QString&
return;
}
KUrl url = theAccount->apiUrl();
url.addPath ( QString("/%1/lists.json").arg(username) );
url.addPath ( "/lists/ownerships.json" );
KUrl url_for_oauth(url);//we need base URL (without params) to make OAuth signature with it!
url.addQueryItem("screen_name", username);
QOAuth::ParamMap params;
params.insert("screen_name", username.toLatin1());
KIO::StoredTransferJob *job = KIO::storedGet ( url, KIO::Reload, KIO::HideProgressInfo ) ;
if ( !job ) {
kError() << "TwitterMicroBlog::loadUserLists: Cannot create an http GET request!";
return;
}
job->addMetaData("customHTTPHeader", "Authorization: " + authorizationHeader(theAccount, url,
QOAuth::GET));
job->addMetaData("customHTTPHeader", "Authorization: " + authorizationHeader(theAccount, url_for_oauth, QOAuth::GET, params));
mFetchUsersListMap[ job ] = username;
mJobsAccount[ job ] = theAccount;
connect ( job, SIGNAL ( result ( KJob* ) ), this, SLOT ( slotFetchUserLists(KJob*) ) );
......@@ -277,10 +281,12 @@ void TwitterMicroBlog::slotFetchUserLists(KJob* job)
i18n("Fetching %1's lists failed. %2", username, job->errorString()), Critical );
} else {
KIO::StoredTransferJob *stj = qobject_cast<KIO::StoredTransferJob *> ( job );
QList<Twitter::List> list = readUserListsFromJson ( theAccount, stj->data() );
QByteArray buffer = stj->data();
QList<Twitter::List> list = readUserListsFromJson ( theAccount, buffer );
if ( list.isEmpty() ) {
kDebug() << buffer;
QString errorMsg;
errorMsg = checkForError(stj->data());
errorMsg = checkForError(buffer);
if( errorMsg.isEmpty() ){
KMessageBox::information(choqokMainWindow, i18n("There is no list record for user %1", username));
} else {
......
......@@ -26,6 +26,7 @@
#include <KDebug>
#include <klocalizedstring.h>
#include <twitterapihelper/twitterapiaccount.h>
#include <twitterapihelper/twitterapimicroblog.h>
#include <kio/jobclasses.h>
#include <kio/job.h>
#include <QDomElement>
......@@ -106,11 +107,10 @@ void TwitterSearch::requestSearchResults(const SearchInfo &searchInfo,
return;
}
TwitterAccount *acc = qobject_cast<TwitterAccount*>(searchInfo.account);
QByteArray auth = acc->oauthInterface()->createParametersString( tmpUrl.url(), QOAuth::GET, acc->oauthToken(),
acc->oauthTokenSecret(), QOAuth::HMAC_SHA1,
param, QOAuth::ParseForHeaderArguments );
job->addMetaData("customHTTPHeader", "Authorization: " + auth);
TwitterAccount* account = qobject_cast< TwitterAccount* >(searchInfo.account);
TwitterApiMicroBlog *microblog = qobject_cast<TwitterApiMicroBlog*>(account->microblog());
job->addMetaData("customHTTPHeader", "Authorization: " + microblog->authorizationHeader(account, tmpUrl, QOAuth::GET, param));
mSearchJobs[job] = searchInfo;
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( searchResultsReturned( KJob* ) ) );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment