-
Notifications
You must be signed in to change notification settings - Fork 9
/
instagram-v1-1.0.js
98 lines (78 loc) · 2.56 KB
/
instagram-v1-1.0.js
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
88
89
90
91
92
93
94
95
96
97
98
/**
* Instagram Cloud Module
* @name Instagram
*
* Cloud Module for using Instagram API.
*
* To use this Cloud Module in Cloud Code, start by requiring
* the <code>mailgun</code> module and initializing it using your
* Mailgun domain name and api key.
*
* <pre>var Instagram = require('cloud/instagram-v1-1.0.js');
* Instagram.initialize('clientId');</pre>
*
*/
(function() {
var _apiUrl = 'https://api.instagram.com/v1/';
var _clientID = '';
var _accessToken = '';
function wrappedHttpRequest(url, params, authenticateRequest) {
authenticateRequest = authenticateRequest || false;
if (authenticateRequest) {
params.access_token = _accessToken;
} else {
params.client_id = _clientID;
}
return Parse.Cloud.httpRequest({
url: url,
params: params
});
}
module.exports = {
initialize: function(clientID) {
_clientID = clientID;
},
setAccessToken: function(accessToken) {
_accessToken = accessToken;
},
searchTag: function(params) {
return wrappedHttpRequest(_apiUrl + "tags/search", params);
},
searchUser: function(params) {
return wrappedHttpRequest(_apiUrl + "users/search", params);
},
searchLocation: function(params) {
return wrappedHttpRequest(_apiUrl + "locations/search", params);
},
getTag: function(tag, params) {
return wrappedHttpRequest(_apiUrl + "tags/" + tag, params);
},
getUser: function(user, params) {
return wrappedHttpRequest(_apiUrl + "users/" + user, params);
},
getLocation: function(location, params) {
return wrappedHttpRequest(_apiUrl + "locations/" + location, params);
},
getPopularMedia: function(params) {
return wrappedHttpRequest(_apiUrl + "media/popular", params);
},
getRecentMediaByTag: function(tag, params) {
return wrappedHttpRequest(_apiUrl + "tags/" + tag + "/media/recent", params);
},
getRecentMediaByUser: function(user, params) {
return wrappedHttpRequest(_apiUrl + "users/" + user + "/media/recent", params, true);
},
getRecentMediaByLocation: function(location, params) {
return wrappedHttpRequest(_apiUrl + "locations/" + location + "/media/recent", params);
},
getSelfFeed: function(params) {
return wrappedHttpRequest(_apiUrl + "users/self/feed", params, true);
},
getSelfLikedMedia: function(params) {
return wrappedHttpRequest(_apiUrl + "users/self/media/liked", params, true);
},
getNextPage: function(nextUrl) {
return wrappedHttpRequest(nextUrl, {});
}
}
})();