Last active
August 29, 2015 13:57
-
-
Save andrefrd/9520512 to your computer and use it in GitHub Desktop.
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
/* | |
*Função PHP Google +1 Count | |
*Author: André Dantas | |
*email: andrefrd (at) gmail (dot) com | |
*/ | |
function gPlusCount( $url ) { | |
$contents = file_get_contents( 'https://plusone.google.com/_/+1/fastbutton?url=' . $url ); | |
preg_match( '/window\.__SSR = {c: ([\d]+)/', $contents, $matches ); | |
if( isset( $matches[0] ) ) | |
return (int) str_replace( 'window.__SSR = {c: ', '', $matches[0] ); | |
return 0; | |
} | |
gPlusCount($url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment