Skip to content

Instantly share code, notes, and snippets.

@cherenkov
Created May 5, 2012 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cherenkov/2601601 to your computer and use it in GitHub Desktop.
Save cherenkov/2601601 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Google+ API test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script language="javascript">
var apiKey = 'ここに自分のGoogle API Keyを入れてください';
function reloadActivityList() {
$.ajax({
type: 'GET',
dataType: 'jsonp',
url: 'https://www.googleapis.com/plus/v1/people/' + $('#userId').val() + '/activities/public?key=' + apiKey,
success: function(msg) {
$.each(msg.items, function(i, item) {
var li = $('<li>').append($('<p>').text(item.title));
if (item.object.attachments) {
$.each(item.object.attachments, function(ii, obj) {
if (obj.objectType == 'photo') {
li.append($('<img>').attr('src', obj.fullImage.url))
}
});
}
$('#activityList').append(li);
});
}
});
}
</script>
</head>
<body>
<input type="text" id="userId" value="104375100134443203420">
<button onclick="reloadActivityList();">Reload</button>
<ul id="activityList"></ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment