Esempio n. 1
0
$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 TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
twitteroauth_row('oauth/reqeust_token', $oauth->getRequestToken(), $oauth->http_code);
Esempio n. 2
0
<?php

/* Start session and load library. */
session_start();
require_once dirname(__DIR__) . '/TwitterOAuth.php';
require_once __DIR__ . '/config.php';
use twitteroauth\TwitterOAuth;
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$connection->enableDebug();
// uncomment to collect additional debug info
/* Get temporary credentials. */
try {
    $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'];
    /* Build authorize URL and redirect user to Twitter. */
    $url = $connection->getAuthorizeURL($token);
    header('Location: ' . $url);
} catch (\OAuthException $e) {
    $responseInfo = $connection->getLastResponseInfo();
    echo "Could not connect to Twitter ({$e->getMessage()}). Refresh the page or try again later.";
    ///* uncomment for some additional debug info
    echo "<pre>Response:\n" . print_r($responseInfo, true) . "\n\nSESSION:\n" . print_r($_SESSION, true) . "\n" . print_r($connection->getDebugInfo(), true) . "\n</pre>\n";
    //*/
}