【发布时间】:2019-11-30 07:53:34
【问题描述】:
我正在尝试获取 Instagram 帐户的帖子计数,我已设法进行关注和关注,但无法正确获取帖子计数。
<?php
$username = 'instagram';
$response = @file_get_contents( "https://www.instagram.com/$username/?__a=1" );
if ( $response !== false ) {
$data = json_decode( $response, true );
if ( $data !== null ) {
$full_name = $data['graphql']['user']['full_name'];
$follower = $data['graphql']['user']['edge_followed_by']['count'];
$follows = $data['graphql']['user']['edge_follow']['count'];
echo "<p>{$full_name}</p> <p>{$follower} followers {$follows} following.</p>";
}
} else {
echo 'Username not found.';
}
?>
【问题讨论】:
标签: instagram-api