Skip to content

Instantly share code, notes, and snippets.

@necenzurat necenzurat/googleplus.php

Last active Sep 27, 2015
Embed
What would you like to do?
Get Google Plus Followers and Following, yea is messy but it does the job done :)
<?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));
@protobyte

This comment has been minimized.

Copy link

protobyte commented Sep 29, 2014

My God.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.