Getting google +1 Page shares via AJAX (hidden Api)

后端 未结 2 961
暗喜
暗喜 2020-12-18 14:34

Struggling to find the solution for getting the Google Plus +1 of page via jQuery - Ajax from Google\'s hidden api: https://clients6.google.com/rpc

T

2条回答
  •  不知归路
    2020-12-18 15:05

    You should be using the official API for Google+ to get +1 counts for pages. The following example from the APIs explorer shows the API call and response data:

    https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=%252BGooglePlusDevelopers&fields=plusOneCount&_h=2&

    A short demo of how to use the API client library:

    1) Async include of the Google+ client / Google API client library

    
    

    When the client loads, set the API key with a key from the Google APIs console:

    gapi.client.setApiKey('YOUR_API_KEY')
    

    Next, load the callback and place an API call once the client is loaded.

    
    

    This will return JSON data that includes the +1 count, e.g.:

    gapi.client.load('plus', 'v1', 
      function(){ 
        gapi.client.plus.people.get(
          {userId: '+GooglePlusDevelopers'}
        ).execute( function(resp){ console.log(resp.plusOneCount); }
        );
      });
    

    Will return 225588, the count of +1s for the page.

提交回复
热议问题