"", 'oauth_access_token_secret' => "", 'consumer_key' => "", 'consumer_secret' => "" ); /** Perform a GET request and echo the response **/ /** Note: Set the GET field BEFORE calling buildOauth(); **/ $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; //Retrieve get variables from this URL and declare them in the Twitter JSON query //@Mets, @Angels, @Astros, @Brewers, @Marlins, @Phillies $default_user = "Mets"; if ((!isset($_GET["ID"])) && (!isset($_GET["User"]))){ //If both ID and User are not set, use the default user don't filter tweets $getfield = '?screen_name='.$default_user.'&count=200&exclude_replies'; }else if ((!isset($_GET["ID"])) && (isset($_GET["User"]))){ //if only the User is set, don't filter tweets by ID $getfield = '?screen_name='.$_GET["User"].'&count=200&exclude_replies'; }else if ((isset($_GET["ID"])) && (!isset($_GET["User"]))){ //if only the ID is set, default the user and filter tweets older than the ID $getfield = '?screen_name='.$default_user.'&count=200&exclude_replies&since_id='.$_GET["ID"]; }else{ //if both User and ID are set, use them $getfield = '?screen_name='.$_GET["User"].'&count=200&exclude_replies&since_id='.$_GET["ID"]; } $requestMethod = 'GET'; $twitter = new TwitterAPIExchange($settings); $json = $twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(); $decoded = json_decode($json); echo "
"; foreach($decoded as $tweet) { if ( preg_match('/\b(hr|homerun|home run|homer|slam)\b/i', $tweet->text)){ echo "
{$tweet->user->screen_name}
"; echo "
{$tweet->id_str}
"; echo "
{$tweet->created_at}
"; echo "
{$tweet->text}

\n"; } } ?>