PHP Script: Get GitHub Followers Count (API v3)

PHP Script: Get GitHub Followers Count (API v3)

Php GitHub Followers Count

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

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