Guest User

Untitled

a guest
Nov 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. <?php include 'php/getTweets.php' ?>
  2.  
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6. <!-- Required meta tags -->
  7. <meta charset="utf-8">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  9.  
  10. <link href="https://fonts.googleapis.com/css?family=Raleway:400,900" rel="stylesheet">
  11. <link rel="stylesheet" href="css/ionicons.min.css">
  12. <!-- Bootstrap CSS -->
  13. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  14. <link rel="stylesheet" href="css/styles.css">
  15. </head>
  16. <body>
  17.  
  18. <div class="overlay">
  19. <div class="input">
  20. <input type="text" placeholder="search"><i class="ion-ios-search-strong"></i>
  21. </div>
  22. </div>
  23.  
  24. <!-- jQuery first, then Bootstrap JS. -->
  25. <script src="https://code.jquery.com/jquery-3.2.1.min.js"
  26. integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  27. crossorigin="anonymous"></script>
  28. <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
  29. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
  30. <script src="js/script.js"></script>
  31. </body>
  32. </html>
  33.  
  34. $(document).ready(function(){
  35.  
  36. $('i').click(function() {
  37. // save search input
  38. var searchTerm = $('input').val();
  39.  
  40. $.ajax({
  41. type: 'GET',
  42. url: "../php/index.php",
  43. dataType: 'JSON',
  44. data: {
  45. searchTerm: searchTerm
  46. },
  47. success: function(data) {
  48. console.log(data);
  49. }
  50. })
  51.  
  52. })
  53. });
  54.  
  55. <?php
  56.  
  57. //Store search input
  58. $searchTerm = $_GET['searchTerm'];
  59.  
  60. //Keys and tokens
  61. $consumer_key = '';
  62. $consumer_secret = '';
  63. $access_token = '';
  64. $access_token_secret = '';
  65.  
  66. //Include Library
  67. require "twitteroauth-master/autoload.php";
  68. use AbrahamTwitterOAuthTwitterOAuth;
  69.  
  70. //Connect to API
  71. $connection = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret);
  72. $content = $connection->get("account/verify_credentials");
  73.  
  74. //Get Tweets
  75. $statuses = $connection->get("search/tweets", [q => "Cats", "count" => 1, "result_type" => "popular"]);
  76.  
  77. print_r($statuses);
  78. ?>
Add Comment
Please, Sign In to add comment