【发布时间】:2020-01-31 20:50:18
【问题描述】:
这是一个简单的示例,此代码无需 API 即可获取任何 Instagram 用户的关注者数量。
$otherPage = 'nasa';
$response = file_get_contents("https://www.instagram.com/$otherPage/?__a=1");
if ($response !== false) {
$data = json_decode($response, true);
if ($data !== null) {
$follows = $data['graphql']['user']['edge_follow']['count'];
$followedBy = $data['graphql']['user']['edge_followed_by']['count'];
echo $follows . ' and ' . $followedBy;
}
}
此代码在我的本地主机和我朋友的服务器上工作,但在我的共享主机中它不起作用:(
file_get_contents 函数运行良好,但仅适用于内部文件而非在线链接。
有人知道为什么吗?
【问题讨论】:
标签: php instagram file-get-contents shared-hosting