<?php /* Start session and load library. */ session_start(); require_once 'config.php'; /* Build TwitterOAuth object with client credentials. */ $connection = new Twitter\TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET); /* Get temporary credentials. */ $request_token = $connection->getRequestToken(OAUTH_CALLBACK); /* Save temporary credentials to session. */ $_SESSION['oauth_token'] = $token = $request_token['oauth_token']; $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret']; /* If last connection failed don't display authorization link. */ switch ($connection->http_code) { case 200: /* Build authorize URL and redirect user to Twitter. */ $url = $connection->getAuthorizeURL($token); header('Location: ' . $url); break; default: /* Show notification if something went wrong. */ echo 'Could not connect to Twitter. Refresh the page or try again later.'; }
$method = 'friends/ids'; twitteroauth_row($method, $connection->get($method), $connection->http_code); /* friends/ids */ $method = 'friends/ids'; twitteroauth_row($method, $connection->get($method), $connection->http_code); /** * Account Methods. */ twitteroauth_header('Account Methods'); /* account/verify_credentials */ $method = 'account/verify_credentials'; twitteroauth_row($method, $connection->get($method), $connection->http_code); /* account/rate_limit_status */ $method = 'account/rate_limit_status'; twitteroauth_row($method, $connection->get($method), $connection->http_code); /* account/update_profile_colors */ $parameters = array('profile_background_color' => 'fff'); $method = 'account/update_profile_colors'; twitteroauth_row($method, $connection->post($method, $parameters), $connection->http_code, $parameters); /* account/update_profile */ $parameters = array('location' => 'Teh internets'); $method = 'account/update_profile'; twitteroauth_row($method, $connection->post($method, $parameters), $connection->http_code, $parameters); /** * OAuth Methods. */ twitteroauth_header('OAuth Methods'); /* oauth/request_token */ $oauth = new Twitter\TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET); twitteroauth_row('oauth/reqeust_token', $oauth->getRequestToken(), $oauth->http_code);