Last active
September 27, 2015 20:57
-
-
Save necenzurat/1330288 to your computer and use it in GitHub Desktop.
Get Google Plus Followers and Following, yea is messy but it does the job done :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* © WTFPL | |
* by necenzurat | |
* Updated: 19 May 2013 | |
*/ | |
$id = @$_GET["id"]; | |
//$id = "108520002754793822340"; | |
$link = "https://plus.google.com/u/0/$id/posts?hl=en"; | |
$data = file_get_contents("$link"); | |
//<span role="button" class="a-n S1xjN" tabindex="0">1.001 persoane</span> | |
function get_my_google_plus_profile($data) | |
{ | |
// 'have X in circles' element | |
preg_match('/<span role="button" class="a-n S1xjN" tabindex="0">(.*?)<\/span>/s', $data, $followers); | |
if (isset($followers) && !empty($followers)) | |
{ | |
$count = $followers[1]; | |
$circles1 = preg_replace('/[^0-9_]/', '', $count); | |
} | |
if (empty($circles)) | |
{ | |
$circles = 0; | |
} | |
// 'in x circles' element | |
preg_match('/<span role="button" class="a-n Cl7aRc" tabindex="0">(.*?)<\/span>/s', $data, $following); | |
if (isset($following) && !empty($following)) | |
{ | |
$count = $following[1]; | |
$circles2 = preg_replace('/[^0-9_]/', '', $count); | |
} | |
if (empty($circles)) | |
{ | |
$circles = 0; | |
} | |
$return = array('followers' => @$circles1, | |
'following' => @$circles2 | |
); | |
return $return; | |
} | |
var_dump(get_my_google_plus_profile($data)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My God.