diff --git a/examples/sialis/README.md b/examples/sialis/README.md index 892a610..cb8dad3 100644 --- a/examples/sialis/README.md +++ b/examples/sialis/README.md @@ -1,5 +1,13 @@ # Sialis -Twitter demo for O2, demonstrating authenticating with Twitter and signing requests in order to show tweets. +GUI demo for O2, demonstrating using O2 from QML, authenticating with Twitter and sending signed requests in order to show some tweets. +To try out Sialis: +1. Login to developer.twitter.com with your Twitter credentials +1. Create a new application "Sialis", record its API Key and API Secret + * Enable OAuth 1.0a authentication + * Set the callback URI to _http://127.0.0.1:8888/_ +1. In _main.qml_, change the O1Twitter object's _clientId_ property to the application's API Key +1. Change the _clientSecret_ property to the application's API secret +1. Build and run, press the _Login_ button to log in to Twitter and show the latest tweets diff --git a/examples/sialis/main.qml b/examples/sialis/main.qml index 4e3ae65..972ff4b 100644 --- a/examples/sialis/main.qml +++ b/examples/sialis/main.qml @@ -1,7 +1,7 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.4 -import QtWebView 1.1 -import com.pipacs.o2 1.0 +import QtQuick +import QtQuick.Controls +import QtWebView +import com.pipacs.o2 ApplicationWindow { id: app @@ -13,8 +13,9 @@ ApplicationWindow { O1Twitter { id: o1Twitter - clientId: "2vHeyIxjywIadjEhvbDpg" - clientSecret: "Xfwe195Kp3ZpcCKgkYs7RKfugTm8EfpLkQvsKfX2vvs" + clientId: "The app's API Key from developer.twitter.com" + clientSecret: "The app's API Secret from developer.twitter.com " + localPort: 8888 onOpenBrowser: { browser.url = url @@ -36,7 +37,7 @@ ApplicationWindow { authenticator: o1Twitter } - statusBar: StatusBar { + footer: ToolBar { Label { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter diff --git a/src/o1.cpp b/src/o1.cpp index b472084..999072a 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -30,7 +30,7 @@ O1::O1(QObject *parent, QNetworkAccessManager *manager, O0AbstractStore *store): setSignatureMethod(O2_SIGNATURE_TYPE_HMAC_SHA1); manager_ = manager ? manager : new QNetworkAccessManager(this); qRegisterMetaType("QNetworkReply::NetworkError"); - + setCallbackUrl(O2_CALLBACK_URL); } @@ -233,13 +233,13 @@ void O1::link() { setToken(""); setTokenSecret(""); setExtraTokens(QVariantMap()); - + if (!useExternalWebInterceptor_) { // Start reply server if (!replyServer()->isListening()) replyServer()->listen(QHostAddress::Any, localPort()); } - + // Get any query parameters for the request #if QT_VERSION >= 0x050000 QUrlQuery requestData; @@ -274,6 +274,10 @@ void O1::link() { headers.append(O0RequestParameter(O2_OAUTH_VERSION, "1.0")); headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE_METHOD, signatureMethod().toLatin1())); headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE, generateSignature(headers, request, requestParameters(), QNetworkAccessManager::PostOperation))); + qDebug() << "O1:link: Token request headers:"; + foreach(param, headers) { + qDebug() << " " << param.name << "=" << param.value; + } // Clear request token requestToken_.clear();