diff --git a/community/index.php b/community/index.php index 8a3d68b..c6b3008 100644 --- a/community/index.php +++ b/community/index.php @@ -5,24 +5,6 @@ - RetryLife Community - - - +} - +// 3. if its a callback url +if(isset($_GET['oauth_token'])){ + // create a new twitter connection object with request token + $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['request_token'], $_SESSION['request_token_secret']); + // get the access token from getAccesToken method + $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']); + if($access_token){ + // create another connection object with access token + $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); + // set the parameters array with attributes include_entities false + $params =array('include_entities'=>'false'); + // get the data + $data = $connection->get('account/verify_credentials',$params); + if($data){ + // store the data in the session + $_SESSION['data']=$data; + // redirect to same page to remove url parameters + $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; + header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); + } + } +} - - +/* + * PART 3 - FRONT END + * - if userdata available then print data + * - else display the login url +*/ - - - - - - - - - - - - - - - - - - - -
- -
-
- -
-
- - +if(isset($login_url) && !isset($_SESSION['data'])){ + // echo the login url + echo ""; +} +else{ + // get the data stored from the session + $data = $_SESSION['data']; + // echo the name username and photo + echo "Name : ".$data->name."
"; + echo "Username : ".$data->screen_name."
"; + echo "Photo :

"; + // echo the logout button + echo ""; +} + ?> +
@@ -230,20 +189,17 @@