Created
June 15, 2015 12:15
-
-
Save anonymous/73794d18a5784799deb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.factory('feed', function($http, vk, $localStorage){ | |
var owner_id = '-34882023'; | |
var version = '5.34'; | |
var count = '5'; | |
var items = []; | |
var liked; | |
var isLiked = function(itemId){ | |
return vk.call('likes.isLiked', {item_id: itemId, owner_id: owner_id, access_token: $localStorage.token, type: 'post', v: version}).then(function(result){ | |
return result; | |
}, function(err){console.log('err' + err)}); | |
}; | |
return { | |
getFeed: function(offset){ | |
return vk.call('wall.get', {owner_id: owner_id, offset: offset, count: count, v: version}).then(function(res){ | |
console.log(res); | |
items = res.data.response.items; | |
for(var i = 0; i < items.length; i++){ | |
isLiked(items[i].id).then(function(ress){ | |
if(ress.data.response.liked == true){ | |
console.log(items[i]); | |
} | |
}); | |
} | |
return items; | |
}, function(err){ | |
console.log('cant call'); | |
}); | |
}, | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment