Example #1
0
        }
    }
}
/*
 * TWITTER SEARCH
 */
if (isset($_POST['q']) && isset($_POST['maxResults'])) {
    $key = $TWITTER_DEVELOPER_KEY;
    $secretKey = $TWITTER_DEVELOPER_SECRET;
    $token = $TWITTER_DEVELOPER_TOKEN;
    $secretToken = $TWITTER_DEVELOPER_SECRET_TOKEN;
    $search = $_POST['q'];
    $maxResult = $_POST['maxResults'];
    $search = trim($search);
    $twitter = new TwitterOAuth($key, $secretKey, $token, $secretToken);
    $tweets = $twitter->GET("https://api.twitter.com/1.1/search/tweets.json?q=" . $search . "&count=" . $maxResult . "&lang=fr%20OR%20eu%20OR%20en-US");
    $tweetsres = array();
    $arrayTweet = array();
    if (isset($tweets->statuses)) {
        foreach ($tweets->statuses as $t) {
            $twtinfo = array();
            $twtinfo["user"] = $t->user->name;
            $twtinfo["url"] = "http://twitter.com/Atechtrader/status/" . $t->id_str;
            $twtinfo["tweet"] = $t->text;
            $tweet = '<li class="tweet">';
            $tweet .= $twtinfo["user"] . '<br />';
            $tweet .= '<p><a href="' . $twtinfo["url"] . '">' . $twtinfo["tweet"] . '</a></p>';
            $tweet .= '</li>';
            $tweetsres[] = $tweet;
        }
    }