From: Andrew Dolgov Date: Mon, 22 Nov 2010 13:32:07 +0000 (+0300) Subject: add twitter register/callback server X-Git-Tag: 1.5.0~68 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ff3e303af72c9b57e9bfcab32b34569bf0754c55;p=tt-rss.git add twitter register/callback server --- diff --git a/twitter.php b/twitter.php new file mode 100644 index 00000000..0cf9fd8a --- /dev/null +++ b/twitter.php @@ -0,0 +1,119 @@ +getAccessToken($_REQUEST['oauth_verifier']); + + /* If HTTP response is 200 continue otherwise send to connect page to retry */ + if ($connection->http_code == 200) { + $access_token = db_escape_string(json_encode($access_token)); + + db_query($link, "UPDATE ttrss_users SET twitter_oauth = '$access_token' + WHERE id = ".$_SESSION['uid']); + + } else { + header('Location: twitter.php?op=clear'); + return; + } + + } + + if ($op == 'register') { + + /* Build TwitterOAuth object with client credentials. */ + $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET); + + /* Get temporary credentials. */ + $request_token = $connection->getRequestToken($callback_url); + + /* Save temporary credentials to session. */ + $_SESSION['oauth_token'] = $token = $request_token['oauth_token']; + $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret']; + + if ($connection->http_code == 200) { + $url = $connection->getAuthorizeURL($token); + header('Location: ' . $url); + return; + } + } +?> + + + +Register with Twitter + + + + + + +

Register with Twitter

+ + + +

+ + + + +

+ +
+ + +
+ + +
+ + +
+ + + + + +