问题
I'm trying to get the count of plus one's I have for google plus, I am checking to see if I have the count right with this
https://plusone.google.com/u/0/_/%2B1/fastbutton?count=true&url=MY_URL
I see that google plus rejects my URL (doesn't return 0 or anything)
I wanted to know if anyone can tell me if I have anything wrong in my url, I have these symbols in my url outside of letters and numbers
:
/
.
?
=
&
_
and my url is formatted like this
(protocol)://(server [such as www]).(domain)/(text).php?(text)=(text)&(text)=(digits)&(text)=(text)
回答1:
Use the URL
https://plusone.google.com/_/+1/fastbutton?url=http%3A%2F%2Fwww.yoursite.com%2Fpath%2Fyour%2fcontent
instead and follow the solution found in this question (parse for window.__SSR = {c:
)
回答2:
I think you're looking for this. It's ugly and Google clearly doesn't support it, but it still works.
function shinra_gplus_get_count( $url ) {
$contents = file_get_contents(
'https://plusone.google.com/_/+1/fastbutton?url='
. urlencode( $url )
);
preg_match( '/window\.__SSR = {c: ([\d]+)/', $contents, $matches );
if( isset( $matches[0] ) )
return (int) str_replace( 'window.__SSR = {c: ', '', $matches[0] );
return 0;
}
来源:https://stackoverflow.com/questions/12043558/google-plus-count-url