Skip to content

Instantly share code, notes, and snippets.

@mikestratton
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikestratton/2de20cad42e4988e5298 to your computer and use it in GitHub Desktop.
Save mikestratton/2de20cad42e4988e5298 to your computer and use it in GitHub Desktop.
Connect to Twitter API, perform search and return results as JSON formatted data.
<?php
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q=PSYCHO&result_type=recent&count=100';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment