-2

I want to check if a user is private on Instagram. When searching on the internet I found this: Getting basic information from Instagram using PHP

$raw = file_get_contents('https://www.instagram.com/USERNAME'); 
preg_match('/\"followed_by\"\:\s?\{\"count\"\:\s?([0-9]+)/',$raw,$m);
print intval($m[1]);

Which uses a regex to check the number of followers for a user.
Now I'm trying to use a regex to check if a user is private or not but I'm unable to figure it out. The field is stated in the JSON response as is_private but I have not been able to get it working.

Is this the right way to do it?

1 Answers1

2

Your not going to want to do that with Regex, instead check the web page

$instagramPage = strip_tags(file_get_contents('http://instagram.com/Username'));
if (strpos($instagramPage,'"is_private":true') !== false) {
    return 'Account is private';
} else {
    return 'Account is public';
}
Tom
  • 685
  • 8
  • 17