Created
May 5, 2012 11:08
-
-
Save cherenkov/2601601 to your computer and use it in GitHub Desktop.
google+ API demo http://q.hatena.ne.jp/1336209956
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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