github-logo-transparent

PHP GitHub followers count script (v3.0 API)

Php GitHub Followers Count

The following PHP GitHub Followers Count script is using the v3.0 GitHub API.

 

Overview

 I’ll explain how to get your github  followers count using PHP.

 

Get Followers Count



<?php
function curl_get_contents($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$github_data = json_decode(curl_get_contents('https://api.github.com/users/your-user-name'), true);
$github_followers_count = $github_data['followers'];
echo $github_followers_count;
?>

 

 

More information

This article was based on the work of Jimbo and Meenakshi Sundaram R

Development Specialist, Artist and Activist
Personal Website

Leave a Reply

Your email address will not be published.


*