I just started playing around with the google+ API and have scoured the docs. It seems pretty straight forward. According to google, a call on their API returns json. Why then do I have to stringify the json before parsing the json before I call key values in jQuery? Here is the sample of code I am working with:
$.ajax({
url: "https://www.googleapis.com/plus/v1/people/{user number}/activities/public?key={my api key}",
data: {
"maxResults": 20,
"verb": "post"
},
dataType: "json",
type: "get",
success: function (data) {
var num_actual_posts = 0;
data = $.parseJSON(JSON.stringify(data));
var listElements = $('ul#googleFeedUL li');
for (var i = 0; i < data.items.length; i++) {
if (data.items[i].verb == "post") {
$(listElements[num_actual_posts]).append(data.items[i].object.content);
num_actual_posts++;
if (num_actual_posts > 5) {
break;
}
}
}
},
error: function (e) {
alert(e);
}
});
NOTE: I have to call 20 posts, because "shares" made by user also get returned when "post" verb is requested for some reason. I then look for actual posts within the returned json in order to display only real posts. The docs also don't seem to tell you how to extract data by explaining the json object hierarchy, so I just had to track it down through the console. 'data.items[i].object.content' is the content of a google+ post.
data = $.parseJSON(JSON.stringify(data));
?