Sunday, August 18, 2013

Twitter Hashtag Php Search Simple example



1. Create a app at dev.twitter.com/apps
2. php code below also download the library should work as it is

require_once('TwitterAPIExchange.php');



/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "get from dev.twitter.com/apps/your apps settings",
'oauth_access_token_secret' => "get from dev.twitter.com/apps/your apps settings",
'consumer_key' => "get from dev.twitter.com/apps/your apps settings",
'consumer_secret' => "get from dev.twitter.com/apps/your apps settings"
);

$twitter = new TwitterAPIExchange($settings);


$url = 'https://api.twitter.com/1.1/search/tweets.json';
$requestMethod = 'GET';
$getfield = '?q=#HarshalTestingTwitter&result_type=recent';

// Perform the request
$twitter = new TwitterAPIExchange($settings);
print_r( $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest());

No comments:

Post a Comment