Skip to content

Instantly share code, notes, and snippets.

@yitsushi
Created November 9, 2014 18:08
Show Gist options
  • Select an option

  • Save yitsushi/2699b24bb590aef6db10 to your computer and use it in GitHub Desktop.

Select an option

Save yitsushi/2699b24bb590aef6db10 to your computer and use it in GitHub Desktop.
<?php
if (array_key_exists('profileUrl', $_POST)) {
$url = $_POST['profileUrl'];
} else {
$url = "https://plus.google.com/u/0/+SergeyBrin/posts";
}
$url = preg_replace('/u\/\d+\//', '', $url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
preg_match('/data:\["(\d+)",/', $response, $matches);
$profileId = $matches[1];
preg_match('/<title itemprop="name">(.*) - Google\+<\/title>/', $response, $matches);
$name = $matches[1];
echo "<h1>Google Play Activity: " . htmlentities($name) . "</h1>";
$url = 'https://play.google.com/store/people/details?id=' . $profileId;
echo "<a href='" . $url . "' target='_blank'>" . $url . "</a>";
?>
<form method="post">
Profile URL: <input type="text" name="profileUrl" placeholder="Google+ Profile URL">
<input type="submit" value="Get the Activity URL">
</form>
<h2>Examples:</h2>
<ul>
<li>https://plus.google.com/u/0/+SergeyBrin/posts</li>
<li>https://plus.google.com/u/0/+YehudaKatz/posts</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment