Now I load the tweets from twitter by using a username like this: (keys and tokens are filled in my code)
<?php
session_start();
require_once("twitteroauth/twitteroauth.php"); // PATH TO TWITTEROUTH LIBRARY
if(isset($_GET['twitteruser']) && !empty($_GET['twitteruser'])) {
$twitteruser = $_GET['twitteruser']; // USER
}
$notweets = 60; // NUMBER OF TWEETS
// OAUTH SETTINGS APPLICATION (https://dev.twitter.com/apps/)
$consumerkey = "";
$consumersecret = "";
$accesstoken = "";
$accesstokensecret = "";
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets);
$data = json_encode($tweets);
?>
As you can see I load the tweets with a username and set the number of tweets.
Can this easily be changed to load tweets with a search term?
I've search on google but strangely I can't find much.
I've found this in the twitter API but that doesn't seem to work ..
source: https://dev.twitter.com/docs/api/1.1/get/search/tweets
(I changed the link to that link)
But I get this output with a var_dump:
string(319) "{"statuses":[],"search_metadata":{"completed_in":0.004,"max_id":2.50126199841e+17,"max_id_str":"250126199840518145","query":"%23freebandnames","refresh_url":"?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1","count":4,"since_id":2.40126199841e+16,"since_id_str":"24012619984051000"}}".....
since_id
) just to make sure you get some results. – Quasdunk