gpt4 book ai didi

instagram-api - Instagram API : Can i check if user is verified?

转载 作者:行者123 更新时间:2023-12-04 18:40:01 25 4
gpt4 key购买 nike

我想知道是否有任何方法可以使用 Instagram API 检查用户验证徽章?

我看到了 https://api.instagram.com/v1/users/如果用户通过验证,{user-id} 不会返回,但是如果您查看用户页面的源代码,您可以看到它有一个名为 isVerified 键的 bool 值,它是用户的 json 结构中的值。

谢谢!

最佳答案

好的,这不是一个很好的答案,但这是我如何完成同样的任务。一旦我从 API 获得用户名,我就会在他们的个人资料页面的来源上执行以下正则表达式:

$response = file_get_contents('https://instagram.com/'.$username);
if (preg_match('/"user":\{"username":"'.$username.'",.*?"isVerified":true\},"__path":".*?'.$username.'.*?"/s', $response) || preg_match('/<meta content=".*?official.*?account.*?" name="description" \/>/is', $response)) {
print "VERIFIED USER!";
}

正如我之前所说,这是 super hacky,但API 目前不提供isVerified 值。在他们这样做之前,我正在使用这个正则表达式。它查找您引用的 JSON 结构的 "isVerified":true 部分。 (例如: https://instagram.com/taylorswift )

我们还添加了一个额外的检查,如果元内容标签中有“官方帐户”,那么我们假设它是官方的。 (例如: https://instagram.com/3doorsdown)我们添加了此检查,因为 Instagram 于 2014 年开始做经过验证的帐户,并且有相当多的名人尚未获得经过验证的徽章。它应该会捡起一些碎片,但也很可能会带来误报。

注意:如果 Instagram 更改了其页面上的 JSON 结构或元标记,此解决方案将失效,因此使用风险自负。我们只需要一个脚本来检查少量用户名是否有经过验证的徽章,我很快就想到了这个。最好的解决方案是每当他们更新他们的 API 时。

关于instagram-api - Instagram API : Can i check if user is verified?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28284465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com