php - How to get the number of times a particular URL has been shared on Google+? -
php - How to get the number of times a particular URL has been shared on Google+? -
i'm using google+ share link on website allow visitors share particular page on google+
for example:
https://plus.google.com/share?url=http://example.com
how can number of times particular url has been shared?
please note: i'm not trying number of times page has been +1'd.
you can track number of shares using google+ ripples (about). however, there not exist official api , perchance never will.
parse number of shares using this snippet:
$shares_url = 'https://plus.google.com/ripple/details?url='. $url; $response = file_get_contents( $shares_url ); $shares_match = preg_match('@<div[^0-9]*([0-9]+) public share[s]?\.</div>@',$response,$matches); if (!empty($matches)) { $shares = $matches[1]; } else { $shares = 0; } echo $shares; note regex tries specify number closely possible, since there might comment on right hand side of page saying like
10 public shares me!
which otherwise match.
php google-plus
Comments
Post a Comment