Advertisement
eberger

Foursquare - Get Tips

Sep 17th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.28 KB | None | 0 0
  1. <?php
  2. $today = date("Ymd");
  3. $likes = 0;
  4. $todo = 0;
  5.  
  6. echo "<table border='1' cellspacing='0' cellpadding = '1' id='resultTable'>";
  7. echo "<thead><tr><th style = 'width: 75px;'>Tip Date</th><th style = 'width: 100px;'>Venue Name</th><th style = 'width: 200px;'>Tip Text</th><th style = 'width: 50px;'>Likes</th><th style = 'width: 50px;'>Saves</th></tr></thead><tbody>";
  8. $url="https://api.foursquare.com/v2/lists/{user-id}/tips?oauth_token={oauth_token}&limit=200&v={$today}";
  9. $source = file_get_contents($url);
  10. $obj = json_decode($source, true);
  11. foreach($obj['response']['list']['listItems']['items'] as $item)
  12.  
  13. {
  14. echo "<tr>";
  15. echo "<td  style = 'width: 75px;'>" .  date('m/d/y', $item['createdAt']) . "</td>" ;
  16. echo "<td  style = 'width: 200px;'>" . $item['venue']['name'] . "</td>" ;    
  17. echo "<td  style = 'width: 400px;'>" . $item['tip']['text'] . "</td>" ;
  18. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['likes']['count'] . "</td>" ;
  19. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['todo']['count'] . "</td>" ;
  20. echo "</tr>";
  21. $likes += $item['tip']['likes']['count'];
  22. $todo += $item['tip']['todo']['count'];
  23. }
  24.  
  25. $url="https://api.foursquare.com/v2/lists/{user-id}/tips?oauth_token={oauth_token}&limit=200&offset=200&v={$today}";
  26. $source = file_get_contents($url);
  27. $obj = json_decode($source, true);
  28. foreach($obj['response']['list']['listItems']['items'] as $item)
  29.  
  30. {
  31.  
  32. echo "<tr>";
  33. echo "<td  style = 'width: 75px;'>" .  date('m/d/y', $item['createdAt']) . "</td>" ;
  34. echo "<td  style = 'width: 200px;'>" . $item['venue']['name'] . "</td>" ;    
  35. echo "<td  style = 'width: 400px;'>" . $item['tip']['text'] . "</td>" ;
  36. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['likes']['count'] . "</td>" ;
  37. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['todo']['count'] . "</td>" ;
  38. echo "</tr>";
  39. $likes += $item['tip']['likes']['count'];
  40. $todo += $item['tip']['todo']['count'];
  41.  
  42. }
  43. $url="https://api.foursquare.com/v2/lists/{user-id}/tips?oauth_token={oauth_token}&limit=200&offset=400&v={$today}";
  44. $source = file_get_contents($url);
  45. $obj = json_decode($source, true);
  46. foreach($obj['response']['list']['listItems']['items'] as $item)
  47.  
  48. {
  49.  
  50. echo "<tr>";
  51. echo "<td  style = 'width: 75px;'>" .  date('m/d/y', $item['createdAt']) . "</td>" ;
  52. echo "<td  style = 'width: 200px;'>" . $item['venue']['name'] . "</td>" ;    
  53. echo "<td  style = 'width: 400px;'>" . $item['tip']['text'] . "</td>" ;
  54. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['likes']['count'] . "</td>" ;
  55. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['todo']['count'] . "</td>" ;
  56. echo "</tr>";
  57. $likes += $item['tip']['likes']['count'];
  58. $todo += $item['tip']['todo']['count'];
  59. }
  60. $url="https://api.foursquare.com/v2/lists/{user-id}/tips?oauth_token={oauth_token}&limit=200&offset=600&v={$today}";
  61. $source = file_get_contents($url);
  62. $obj = json_decode($source, true);
  63. foreach($obj['response']['list']['listItems']['items'] as $item)
  64.  
  65. {
  66.  
  67. echo "<tr>";
  68. echo "<td  style = 'width: 75px;'>" .  date('m/d/y', $item['createdAt']) . "</td>" ;
  69. echo "<td  style = 'width: 200px;'>" . $item['venue']['name'] . "</td>" ;    
  70. echo "<td  style = 'width: 400px;'>" . $item['tip']['text'] . "</td>" ;
  71. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['likes']['count'] . "</td>" ;
  72. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['todo']['count'] . "</td>" ;
  73. echo "</tr>";
  74. $likes += $item['tip']['likes']['count'];
  75. $todo += $item['tip']['todo']['count'];
  76. }
  77. $url="https://api.foursquare.com/v2/lists/{user-id}/tips?oauth_token={oauth_token}&limit=200&offset=800&v={$today}";
  78. $source = file_get_contents($url);
  79. $obj = json_decode($source, true);
  80. foreach($obj['response']['list']['listItems']['items'] as $item)
  81.  
  82. {
  83.  
  84. echo "<tr>";
  85. echo "<td  style = 'width: 75px;'>" .  date('m/d/y', $item['createdAt']) . "</td>" ;
  86. echo "<td  style = 'width: 200px;'>" . $item['venue']['name'] . "</td>" ;    
  87. echo "<td  style = 'width: 400px;'>" . $item['tip']['text'] . "</td>" ;
  88. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['likes']['count'] . "</td>" ;
  89. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['todo']['count'] . "</td>" ;
  90. echo "</tr>";
  91. $likes += $item['tip']['likes']['count'];
  92. $todo += $item['tip']['todo']['count'];
  93. }
  94. $url="https://api.foursquare.com/v2/lists/{user-id}/tips?oauth_token={oauth_token}&limit=200&offset=1000&v={$today}";
  95. $source = file_get_contents($url);
  96. $obj = json_decode($source, true);
  97. foreach($obj['response']['list']['listItems']['items'] as $item)
  98.  
  99. {
  100.  
  101. echo "<tr>";
  102. echo "<td  style = 'width: 75px;'>" .  date('m/d/y', $item['createdAt']) . "</td>" ;
  103. echo "<td  style = 'width: 200px;'>" . $item['venue']['name'] . "</td>" ;    
  104. echo "<td  style = 'width: 400px;'>" . $item['tip']['text'] . "</td>" ;
  105. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['likes']['count'] . "</td>" ;
  106. echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['todo']['count'] . "</td>" ;
  107. echo "</tr>";
  108. $likes += $item['tip']['likes']['count'];
  109. $todo += $item['tip']['todo']['count'];
  110. }
  111. echo "</tbody></table>";
  112. echo "<h3>Totals</h3>";
  113. echo "Likes: " . $likes . "<br>" ;
  114. echo "Saves: " . $todo;
  115.  
  116. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement