-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsearchTweets.php
More file actions
29 lines (22 loc) · 905 Bytes
/
searchTweets.php
File metadata and controls
29 lines (22 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
showTweets("GeekyTheory",5);
function getJsonTweets($query,$num_tweets){
ini_set('display_errors', 1);
require_once('TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
if($num_tweets>100) $num_tweets = 100;
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q='.$query.'&count='.$num_tweets;
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$json = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
return $json;
}