Beispiel #1
0
 *
 * Instructions:
 * 1) If you don't have one already, create a Twitter application on
 *      http://dev.twitter.com/apps
 * 2) From the application details page copy the consumer key and consumer
 *      secret into the place in this code marked with (YOUR_CONSUMER_KEY
 *      and YOUR_CONSUMER_SECRET)
 * 3) Fill in the username and password of the user you wish to obtain
 *      the user token and secret for.
 * 4) Visit this page using your web browser.
 *
 * @author themattharris
 */
require '../tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array('consumer_key' => '9iERUaqhjAUG2kHKLGPZ8g', 'consumer_secret' => 'h7k1zcHCwGMHD7UeF1vQmETpog9ce2bneNsyM3q60Ko'));
$here = $tmhOAuth->php_self();
session_start();
// reset?
if (isset($_REQUEST['wipe'])) {
    session_destroy();
    header("Location: {$here}");
    // already got some credentials stored?
} elseif (isset($_SESSION['access_token'])) {
    $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
    $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
    $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
    $tmhOAuth->pr(json_decode($tmhOAuth->response['response']));
    // we're being called back by Twitter
} elseif (isset($_REQUEST['oauth_verifier'])) {
    $tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
    $tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];