PHP Google Plus计数器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Google Plus计数器相关的知识,希望对你有一定的参考价值。

function get_google_plus1_count($url)
{
  $ch = curl_init();
  curl_setopt_array($ch, array(
    CURLOPT_HTTPHEADER      => array('Content-type: application/json'),
    CURLOPT_POST            => true,
    CURLOPT_POSTFIELDS      => '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.$url.'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]',
    CURLOPT_RETURNTRANSFER  => true,
    CURLOPT_SSL_VERIFYPEER  => false,
    CURLOPT_URL             => 'https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ'
  ));
  $res = curl_exec($ch);
  curl_close($ch);
 
  if( $res )
  {
    $json = json_decode($res,true);
    return $json[0]['result']['metadata']['globalCounts']['count'];
  }
  return false;
}

以上是关于PHP Google Plus计数器的主要内容,如果未能解决你的问题,请参考以下文章

php Facebook,Twitter,Google Plus和LinkedIn的自定义社交分享图标

php Facebook,Twitter,Google Plus和LinkedIn的自定义社交分享图标

Plus.PeopleApi.loadVisible mGoogleApiClient 总是返回零计数 persobuffer

Google plus 跨站身份 Android 转 PHP 访问令牌

Google Plus PHP API 与其他 API 文件冲突

PHP:Google plus Oauth 2.0 - 获取OAuth2访问令牌时出错,消息:'invalid_client'