Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. function id_rand() {
  5.     static $chars = '0123456789abcdefghijklmnopqrstuvwxyz_';
  6.     $result = '';
  7.     for ($i = 0; $i < 5; ++$i) {
  8.         $result .= $chars[mt_rand(0, 36)];
  9.     }
  10.     return $result;
  11. }
  12.  
  13. $fp = fopen('id.rtf', 'a');
  14. $ch = curl_init();
  15. curl_setopt_array($ch, [
  16.     CURLOPT_SSL_VERIFYPEER => false,
  17.     CURLOPT_RETURNTRANSFER => true,
  18. ]);
  19. $checked = [];
  20.  
  21. while (true) {
  22.     while (isset($checked[$id = id_rand()]));
  23.     $checked[$id] = true;
  24.     $url = "https://twitter.com/users/username_available?username={$id}";
  25.     curl_setopt($ch, CURLOPT_URL, $url);
  26.     $json = json_decode(curl_exec($ch), true);
  27.     if (!isset($json['reason'])) {
  28.         die('Decode error. Script has been shut down.');
  29.     }
  30.     echo "{$id} is {$json['reason']}\n";
  31.     if ($json['reason'] === 'available') {
  32.         fwrite($fp, "{$id}\n");
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement