Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- session_save_path("/tmp");
- session_start();
- ini_set('display_errors', 1);
- require_once('TwitterAPIExchange.php');
- //setting the api connection
- $settings = array(
- 'oauth_access_token' => "****",
- 'oauth_access_token_secret' => "****",
- 'consumer_key' => "****",
- 'consumer_secret' => "****"
- );
- $url ="https://api.twitter.com/1.1/search/tweets.json";
- $requestMethod = 'GET';
- //displaying the search results
- $twitter = new TwitterAPIExchange($settings);
- $_SESSION['key'] ='';
- if(isset($_GET['results']))
- {
- $r_count = $_GET['results'];
- }
- if(isset($_GET['keyword']))
- {
- print_r("<p style='padding-left:1em;color:#FFC20E;font-size:20px'>Search Results for Keyword: <span style='font-weight: bold'>".$_GET['keyword']."</span></p><br>");
- $result = '?q=%23'.$_GET['keyword'].'&result_type=recent&count='.$r_count.'';
- $key = $_GET['keyword'];
- $result = preg_replace("/b([a-z]*${key}[a-z]*)b/i","<b>$1</b>",$result);
- $string = $twitter ->setGetfield($result)
- ->buildOauth($url, $requestMethod);
- ->performRequest();
- $response = json_decode($string);
- echo "<table border='1'>";
- echo "<th>Display Name</th>";
- echo "<th>handle</th>";
- echo "<th>Tweet</th>";
- echo "<th>Location</th>";
- foreach($response->statuses as $tweet)
- {
- echo "<tr>";
- //echo "<td> {$tweet->user->name} </td><td><img src={$tweet->user->profile_image_url}/>{$tweet->user->screen_name} </td><td> {$tweet->text}</td><td> {$tweet->user->location}</td>";
- echo '<td>'.$tweet->user->name.'</td><td><img height="35" style="width:35px;display:inline-block" src="'.$tweet->user->profile_image_url.'"/><a style ="color: #0075c9" target="_blank" href="https://twitter.com/'.$tweet->user->screen_name.'">@'.$tweet->user->screen_name.'</a></td><td>'.$tweet->text.'</td><td>'.$tweet->user->location.'</td>';
- echo "</tr>";
- }
- echo "</table>";
- }
Add Comment
Please, Sign In to add comment