Guest User

Untitled

a guest
Jun 20th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2.  
  3. $username = 'user';
  4. $password = 'pass';
  5. $count = 1;
  6.  
  7. do {
  8. $fp = fsockopen("stream.twitter.com", 80, $errno, $errstr, 30);
  9. if (!$fp) {
  10. echo "$errstr ($errno)\n";
  11. } else {
  12. $out = "GET /gardenhose.json HTTP/1.1\r\n";
  13. $out .= "Host: stream.twitter.com\r\n";
  14. $out .= "User-Agent: UserAgent\r\n";
  15. $out .= "Authorization: Basic " . base64_encode($username . ':' . $password)."\r\n";
  16. $out .= "Connection: Close\r\n\r\n";
  17. fwrite($fp, $out);
  18. while (!feof($fp)) {
  19. $line = fgets($fp, 4096);
  20. if ($count > 5) {
  21. if (trim($line) != '') {
  22. $tweet_obj = json_decode(trim($line));
  23. }
  24. }
  25. else {
  26. // view the first 5 lines (headers): uncomment the below line
  27. // echo trim($line) . "\n";
  28. }
  29. $count++;
  30. }
  31. fclose($fp);
  32. }
  33. } while (true);
Add Comment
Please, Sign In to add comment