$search = false;
if (isset($_POST['q']) || isset($_GET['q'])) {
    $search = true;
    $keyword = isset($_POST['q']) ? $_POST['q'] : $_GET['q'];
    $keyword = trim(strip_tags($keyword));
    $params = array();
    if (count($_POST)) {
        $params = array('q' => $keyword, 'count' => 20, 'include_entities' => 1);
    } else {
        if (count($_GET)) {
            $params = $_GET;
        }
    }
    if ($keyword) {
        $data = $twitter->get('search/tweets', $params);
        $data = $twitter->toArray($data);
    }
}
if ($search) {
    //    echo '<pre>';
    //    print_r($data);
    //    echo '</pre>';
    //    exit;
}
$count = 0;
$nav = isset($data['search_metadata']) && $data['search_metadata']->next_results ? true : false;
?>

<!doctype html>
<html>
<head>
Exemple #2
0
@session_start();
require_once 'src/twitteroauth.php';
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
if (!$twitter->isLogged()) {
    $twitter->redirect('/');
}
// https://dev.twitter.com/docs/api/1.1
/* Some example calls */
//$twitter->get('users/show', array('screen_name' => 'abraham'));
//$twitter->post('statuses/update', array('status' => date(DATE_RFC822)));
//$twitter->post('statuses/destroy', array('id' => 5437877770));
//$twitter->post('friendships/create', array('id' => 9436992));
//$twitter->post('friendships/destroy', array('id' => 9436992));
// get user info
$user = $twitter->get('account/verify_credentials');
$user = $twitter->toArray($user);
extract($user);
// get user account settings
$settings = $twitter->get('account/settings');
$settings = $twitter->toArray($settings);
// rate limit exceeded
if (isset($user['errors'])) {
    echo '<pre>';
    print_r($twitter->getRateLimit());
    echo '</pre>';
    exit;
}
//echo '<pre>';
//print_r($user);
//exit;
?>