我想检查用户是否在Instagram上是私密的。在网上搜索时我发现了这个: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]);
它使用正则表达式来检查用户的关注者数量。
现在我正在尝试使用正则表达式来检查用户是否是私有的,但我无法弄明白。该字段在JSON响应中声明为is_private
,但我无法使其正常工作。
这是正确的方法吗?
您不希望使用Regex执行此操作,而是检查网页
$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';
}