Created
April 9, 2014 03:35
-
-
Save altyus/10223831 to your computer and use it in GitHub Desktop.
Parse Cloud code to get Post objects for in network friends with passed in facebook IDs
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
Parse.Cloud.define("friends", function(request, response){ | |
var query = new Parse.Query("User"); | |
query.containedIn("facebook_id", request.params.facebook_ids_array); | |
query.find({ | |
success: function(results){ | |
var friendIDs = new Array(); | |
for (var i = 0; i < results.length; i++) | |
{ | |
friendIDs.push(results[i].get('facebook_id')); | |
} | |
var query = new Parse.Query("Post"); | |
query.containedIn("facebook_id", friendIDs); | |
query.find ({ | |
success: function(results){ | |
console.log(results); | |
response.success(results); | |
}, | |
error: function(){ | |
response.error("Post lookup failed"); | |
} | |
}); | |
}, | |
error: function(){ | |
response.error("Friend lookup failed"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment