-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathscript.js
38 lines (33 loc) · 1.05 KB
/
script.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
var INSTA_API_BASE_URL = "https://api.instagram.com/v1";
var app = angular.module('Instamood',[]);
app.controller('MainCtrl', function($scope, $http) {
// get the access token if it exists
$scope.hasToken = true;
var token = window.location.hash;
console.log(token);
if (!token) {
$scope.hasToken = false;
}
token = token.split("=")[1];
$scope.getInstaPics = function() {
var path = "/users/self/media/recent";
var mediaUrl = INSTA_API_BASE_URL + path;
$http({
method: "JSONP",
url: mediaUrl,
params: {
callback: "JSON_CALLBACK"
// you need to add your access token here, as per the documentation
}
}).then(function(response) {
$scope.picArray = response.data.data;
// now analyze the sentiments and do some other analysis
// on your images
})
};
var analyzeSentiments = function() {
// when you call this function, $scope.picArray should have an array of all
// your instas. Use the sentiment analysis API to get a score of how positive your
// captions are
}
});