php - Trying to validate if Facebook user exist or not from a .txt file -


i have .txt files contains few facebook usernames , want check if usernames exists, i.e if facebook returns real profile or if returns 404 page. want save usernames exists in .txt file.

    function get_data($url) {         $ch = curl_init();         $timeout = 100;          curl_setopt($ch, curlopt_url, $url);         curl_setopt($ch, curlopt_returntransfer, 1);         curl_setopt($ch, curlopt_connecttimeout, $timeout);         curl_setopt($ch,curlopt_useragent,'mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.13) gecko/20080311 firefox/2.0.0.13');         curl_setopt($ch, curlopt_followlocation, true);         curl_setopt($ch, curlopt_ssl_verifypeer, false);          $data = curl_exec($ch);          if (curl_errno($ch)) {             echo 'curl error: ' . curl_error($ch);         }          curl_close($ch);          return $data;     }      $handle = fopen("usernames.txt", "r");      if ($handle) {         while ($username = fgets($handle) !== false) {             echo $url = "https://facebook.com/" . $username;              $source = get_data($url);             if (preg_match_all('/<div class="coverborder">/', $source, $matches))  // if user exists, print name ($line). <div class="coverborder"> confirms user exists since class not exist on facebook's 404 page             echo $matches;         }          fclose($handle);      } else {         echo "error opening file";     }  

i errors:

https://facebook.com/sanna curl error: illegal characters found in urlhttps://facebook.com/asodkasopdkaopsasf curl error: illegal characters found in urlhttps://facebook.com/jana curl error: illegal characters found in urlhttps://facebook.com/henrik 

usernames.txt looks like:

sanna
asodkasopdkaopsasf
jana
henrik


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -