Google Plus Count url

坚强是说给别人听的谎言 提交于 2019-12-25 05:25:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!