-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstagram.js
102 lines (50 loc) · 2.5 KB
/
instagram.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
$( document ).ready(function() {
//Get the URL from the current window and pull accessToken
var accessToken = window.location.href;
accessToken = accessToken.replace("https://advancedwebdesign-daphneacharles.c9users.io/WanderlustAtlas/#access_token=", "");
var clientID = '502c79169511424cb563cac12a8f9f3e';
var dataUrl = 'https://api.instagram.com/v1/users/self/media/recent?access_token=' + accessToken;
//INSTAGRAM AJAX CALL
$.ajax({
url: dataUrl,
type: 'GET',
dataType: 'jsonp',
// cache: false,
data: { //required parameters should go here
count:12,
},
success: function(serverResponse) {
try {
var data = serverResponse.data;
console.log(data);
var myHTML = '';
for(var i = 6; i< data.length; i++){
myHTML += '<li class="insta list-group-item">';
myHTML += '<span class="instaUser">' + data[i].user.username + '</span>' + '<br>';
myHTML += '<span class="instaBody">' + data[i].location.name + '</span>' + '<br>';
myHTML += '<span class="instaBody"><img id="instaPic" src="' + data[i].images.low_resolution.url + '"></span>';
myHTML += '<span class="instaBody badge glyphicon glyphicon-heart">' + data[i].likes.count + '</span>' + '<br>';
myHTML += '<span class="instaBody">' + data[i].caption.text + '</span>' + '<br>';
myHTML += '</li>';
}
$('#output2').append(myHTML);
}
catch (ex) {
console.error(ex);
$("#errors").text("An error occurred processing the data from Instagram");
}
},
error: function(jqXHR, textStatus, errorThrown) {
if (errorThrown == 'Service Unavailable') {
$("#errors").text("Your cloud 9 instance isn't running!");
}
else {
$("#errors").text('An unknown error occurred: ' + errorThrown);
}
},
complete: function() {
allowAjaxHide = true;
$("#ajaxIndicator").modal('hide');
}
});
});