Learn More

Wednesday, December 12, 2012

Get User Information With Blogger API v3

blogger api logo
May be you was saw several application where that app can retrieving your all blogs list of a user. This can do if you are using user information. This can be understanding from our tutorials about basic blogger API v3. That is, user resource are key to track all blogs of a user. With this reason, we decided to continue the discussion about blogger API v3 with Get User Information step. Again, we also provided demo for this discussion so that you will know how exactly user resource is work Please to activating your firebug, because we also provided the result to showed on firebug.

Basically, to get user information with blogger API v3, you need user resource. What you should to know about user resource is a resource that contain secure HTTP request

https://www.googleapi.com/blogger/v3/users/{userId}

with one required parameter

userId

where this required parameter is your ID with string as value of parameter. Sometimes, you don't know your Id, you can change this parameter with

self

Like what we talked before, you must also add access_token parameter after required parameter. So that, what you should to do on secure HTTP request become

https://www.googleapi.com/blogger/v3/users/{userId}?access_token=YOUR-TOKEN

Below is example code how to get user information (with jquery)

<script type="text/javascript">
$('#getUserInfo').click(function(){
          var clientID = 'YOUR-CLIENT-ID';
          var yourID = YOUR-ID;
          gapi.auth.authorize({client_id:clientID,scope:'https://www.googleapis.com/auth/blogger',immediate:true},function(){
                   var yourToken = gapi.auth.getToken().access_token;
                   $.getJSON('https://www.googleapis.com/blogger/v3/users/'+yourID+'?access_token='+yourToken,function(data){
                            alert("your id is = "+data.id);
                            alert("your url = "+data.url);
                   });
          });

});
</script>
<script src="https://apis.google.com/js/client.js"></script>
<button id="getUserInfo">User Info</button> 

Below is the interactive control for you to know how exactly user resource is work. Make sure you was activated your firebug, see the console.

Your ID Scope


Post a Comment