Ejemplo n.º 1
0
<?php

@session_start();
require_once 'src/twitteroauth.php';
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
if (!$twitter->isLogged()) {
    $twitter->redirect('/');
}
// get data
$data = array();
$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);