使用jQuery获取Google+订阅计数 [英] Getting Google+ subscription count with jQuery

查看:129
本文介绍了使用jQuery获取Google+订阅计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以通过相同的方式在 http://上获得Google+订阅总数www.tomanthony.co.uk/google_plus_one_api_example.php ?没有PHP?

Is possible to get the total number of Google+ subscriptions in same way was done on http://www.tomanthony.co.uk/google_plus_one_api_example.php? Without php?

谢谢

更新:我尝试了这段代码,但是没有用

update: i tried with this piece of code but isn't working



function getplusone(url){
     var plusones;
     $.getJSON('https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ' + 'callback=?',
        {
           "method":"pos.plusones.get",
           "id":"p",
           "params":{
              "nolog":true,
              "id":url,
              "source":"widget",
              "userId":"@viewer",
              "groupId":"@self"
           },
           "jsonrpc":"2.0",
           "key":"p",
           "apiVersion":"v1"
        },
        function(data){           
        plusones = data.count;
        $('#feed').html(plusones);
     });
  }

推荐答案

首先,您需要从Google控制台创建一个API密钥-

First you need to create a API Key from Google Console - https://console.developers.google.com

然后,您需要获取需要获得关注者/订阅者人数的页面或个人资料ID.

Then you need to get the Page or Profile Id for which you need to get the followers/subscribers count.

之后,您需要向该网址发送请求- https://www.googleapis.com/plus/v1/people/ {PROFILE_ID }?key = {APIKEY}

After that you need to send a request to this url- https://www.googleapis.com/plus/v1/people/{PROFILE_ID}?key={APIKEY}

使用下面的代码-

var profileid = 'YOUR_PROFILE_ID';
var apikey = 'YOUR_API_KEY';
var url = 'https://www.googleapis.com/plus/v1/people/' + profileid + '?key=' + apikey;
$.ajax({
    type: "GET",
    dataType: "json",
    url: url,
    success: function (data) {
        var googlefollowcount = data.circledByCount;
        $(".googlefollowercount").html(googlefollowcount);
    }
});

请求将像上面这样发送,但是请确保您替换了个人资料ID和API密钥.

The request will be send like this one above but make sure that you replace your Profile ID and API key.

您可以通过以下网址查看并跟踪整个过程- http://www.bloggerever.com /2014/05/how-can-you-get-google-plus-follower.html

You can see and follow the whole process from this url- http://www.bloggerever.com/2014/05/how-can-you-get-google-plus-follower.html

这篇关于使用jQuery获取Google+订阅计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆