Reputation: 19
Trying to see if an IG acc is used or free but it always return false even if the account exists...
<?php
$ch = curl_init("http://www.instagram.com/asd9usa0d0sad90sa90a09d");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$text = curl_exec($ch);
$test = strpos($text, "Sorry, this page");
print_r($text);
if ($test==false)
{
echo "Username exists";
}
else
{
echo "Username does not exist";
}
?>
If an IG acc doesn't exist, example instagram.com/basdlkasld4 then it will disaplay "Sorry, this page isn't available.".
Upvotes: 1
Views: 872
Reputation: 17417
That URL redirects a couple of times before reaching the Sorry, this page... result. If you add the following line, Curl will follow the redirects correctly.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Upvotes: 1