-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
87 lines (79 loc) · 3.62 KB
/
index.html
File metadata and controls
87 lines (79 loc) · 3.62 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title>JavaScript API for MINTPRESSO</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="http://mintpresso.com/assets/stylesheets/bootstrap/bootstrap.css" rel="stylesheet">
<link href="http://mintpresso.com/assets/stylesheets/main.css" rel="stylesheet">
<script type="text/javascript">
(function(e,t,k,o){var n,r,i;r=e.createElement("script");r.type="text/javascript";r.async=!0;r.onload=function(){if('mintpresso' in window){return window.mintpresso.init(t,k,o);}else{console.log("Failed to load API.")}};r.src="mintpresso-0.2.js";n=e.getElementsByTagName("script")[0];return n.parentNode.insertBefore(r,n)})(document,"182b705f1-3db6-466e-9183-d30d1c4866ff",1, {withoutCallback: false, useLocalhost: true, callbackFunction: 'mintpressoInit', disableDebugCallback: false});
</script>
</head>
<body style="padding:40px;">
<h1>JavaScript API for MINTPRESSO</h1>
<p>Go to <a href="http://mintpresso.com/login">Panel</a> > Overview > API Setting. Check out and configure your API Key. You can also get auto generated source code.</p>
<pre>
function mintpressoInit(_){
var user = 0
var music = 0
_.set({type: "user", identifier: "jin"});
_.set({type: "music", identifier: "bugs-1000", artist: "가을방학"});
$.when(
_.get({user: "jin"}, function(json){ user = json.point }),
_.get({music: "bugs-1000"}, function(json){ music = json.point })
).then(
function(){
// all of queries are success
console.log("User: " + user.identifier + "\t Music: " + music.artist)
_.get({user: "jin", did: "listen", music: "bugs-1000"}, function(json){
if(json.status.code == 404){
console.log(music.artist + "의 노래를 아직 듣지 못하셨군요!")
}
});
},
function(){
// one of queries is failed
console.log("Failed to get info.")
}
)
var friend = 0
var listened = 0
$.when(
_.get({user: "jin"}),
_.get({user: "jin", did: "listen", music: "?"})
).done( function(user, list){
/*
Each index of user, music object contains:
0: jsonResponse
1: statusText
2: jqXHR
*/
friend = user[0].point
listenCount = list[0].status.code == 404 ? 0 : list[0]._length
console.log(friend.identifier + "님은 노래 " + 0 + "곡을 들었습니다.")
})
}
(function(e,t,o){var n,r,i;r=e.createElement("script");
r.type="text/javascript";r.async=!0;
r.onload=function(){if('mintpresso' in window){return window["mintpresso"].init(t, o);}else{console.warn('Failed to load mintpresso.js')}};
i="//mintpresso.com/assets/javascript-api/mintpresso-0.2.js";
if("https:"===e.location.protocol){r.src="https:"+i}else{r.src="http:"+i}n=e.getElementsByTagName("script")[0];return n.parentNode.insertBefore(r,n)}
)(document,"1ab4d5f5c-2316-481f-9f8f-a038e9b4bcde",{withoutCallback: false, useLocalhost: true, callbackFunction: 'mintpressoInit', disableDebugCallback: true})
/*
withoutCallback
- whether or not use JSONP
useLocalhost
- use localhost as API server if true
callbackFunction
- specified function will be called just after intialization when mintpresso API is ready to use
disableDebugCallback
- force to do not use default callback; it shows debug messages on console, very handy to debug.
*/
</pre>
© 2013 MINTPRESSO, South Korea.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</body>
</html>