获取谷歌加股数的jQuery [英] Getting google plus shares count with jquery

查看:198
本文介绍了获取谷歌加股数的jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让谷歌,加上股计数与jQuery的URL。

I am trying to get Google plus shares count for a URL with Jquery.

url = 'www.abc.com/';
$.getJSON('https://clients6.google.com/rpc?key=AIzaSyBeAeOUk3BJs9ZXeohJX6Qt2zWXPQsRKRk'+'callback=?',
    {
       "method":"pos.plusones.get",
       "id":"p",
       "params":{
          "nolog":true,
          "id":'http://prince-antil.myshopify.com/',
          "source":"widget",
          "userId":"@viewer",
          "groupId":"@self"
       },
       "jsonrpc":"2.0",
       "key":"p",
       "apiVersion":"v1",         
    },
    function(data){          
    plusones = data.count;
    alert(data);
 });

但是我收到以下错误:

But I am getting following error:

    {
 "error": {
  "code": 400,
  "message": "Bad Request",
  "data": [
   {
    "domain": "usageLimits",
    "reason": "keyInvalid",
    "message": "Bad Request"
   }
  ]
 },
 "id": "p"
}

我已经创建了一个API,但我不知道我已经创造了它的方式。上述错误提示无效的钥匙。我有交叉检查的关键,但最关键的是正确的。我不知道是否有一些特别的东西需要在APP领域进行配置。我是新局。请帮助我。

I have created an API but I am not sure about the way I have created it. Above error says "invalid key". I have cross checked the key but the key is correct. I don't know if there is something special need to configure in the APP area. I am new bie. Please help me out.

感谢。

推荐答案

采取了一些工作,但这种解决方案并获得成功。 (在Firefox和Chrome测试)无需API密钥并没有改变必要。 :)
不要忘了,包括您的jQuery的文件。

Took some work but this solution did the trick. (Tested in Firefox and Chrome) No API Key required and no changes necessary. :) Don't forget to include your jQuery file.

$(window).load(function(){
    /* Social Share: Google Plus JSON */
        var data = {
            "method":"pos.plusones.get",
            "id":"http://www.website_you_want_share_count_for.com",
            "params":{
                "nolog":true,
                "id":"http://www.website_you_want_share_count_for.com",
                "source":"widget",
                "userId":"@viewer",
                "groupId":"@self"
            },
            "jsonrpc":"2.0",
            "key":"p",
            "apiVersion":"v1"
        };
        $.ajax({
            type: "POST",
            url: "https://clients6.google.com/rpc",
            processData: true,
            contentType: 'application/json',
            data: JSON.stringify(data),
            success: function(r){
                $('#googleplus_page_share_count').text(format(r.result.metadata.globalCounts.count));
            }

        });
});

<p><span id="googleplus_page_share_count">256</span> Shares.</p>

这篇关于获取谷歌加股数的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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