Why does it always return 1 for all existing usernames? I'm trying to get the maximum page number of a username If possible, how to get all of someone's followers with a single link? the max value of per_page is 100. this is really annoying
function getMaxPage($userName) {
$page = 0;
do {
$fileName = "https://api.github.com/users/" . $userName . "/followers?page=" . $page . "&per_page=100";
$useIncludePath = false;
$context = stream_context_create(array("http" => array(
"header" => "User-Agent:Mozilla/5.0 (Linux; {Android Version}; {Build Tag etc.}) AppleWebKit/{WebKit Rev} (KHTML, like Gecko) Chrome/{Chrome Rev} Mobile Safari/{WebKit Rev}"
)));
$getFollowersInfo = json_decode(file_get_contents($fileName, $useIncludePath, $context));
$page++;
} while (empty($getFollowersInfo));
return $page;
}
echo getMaxPage("UserName");
source https://stackoverflow.com/questions/72764269/how-to-get-the-largest-page-number-github-api
No comments:
Post a Comment