/
example.html
42 lines (33 loc) · 1.32 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<title>Examples</title>
</head>
<body>
<h1>Super Simple JSONP Examples</h1>
<div id="flickrPic"></div>
<div id="avatar"></div>
<div id="github"></div>
<div id="facebook"></div>
<script src="JSONP-min.js"></script>
<script>
//Flickr Example
JSONP('http://api.flickr.com/services/feeds/photos_public.gne',{'id':'12389944@N03','format':'json'},'jsoncallback',function(json){
document.getElementById('flickrPic').innerHTML = '<p>Flickr Pic:</p><img src="'+json.items[0].media.m+'">';
});
//Twitter Example
JSONP('http://twitter.com/users/oscargodson.json',function(json){
document.getElementById('avatar').innerHTML = '<p>Twitter Pic:</p><img src="'+json.profile_image_url+'">';
});
//Github Example
//https://api.github.com/users/carvefx/gists?since=2014-02-01T12:00:00Z
JSONP('https://api.github.com/users/carvefx/gists',{'since': '2014-02-01T12:00:00Z'},function(json){
document.getElementById('github').innerHTML = json.data[0].html_url;
});
//Facebook Graph Example
JSONP('http://graph.facebook.com/FacebookDevelopers', 'callback', function(json){
document.getElementById('facebook').innerHTML = json.about;
});
</script>
</body>
</html>