0

I am trying to get a list of friends from Facebook and then change the values to parse user id like this:

I got the friends list from Facebook and I try to get any item that has install item in it.

Then I try to replace the install: true with parse user id by querying the FB id to the FB I got stored in parse .com (at app install). The problem is that parse doesn't return any values no error/success msg no nothing.

 Parse.Cloud.define("fbtomo3", function(request, response)
 {
  var fbid =request.user.get('FaceBookId');
  var fbtoken = request.user.get('authData').facebook.access_token;
  var listFromFB ="";
  Parse.Cloud.httpRequest(
  {
   url:"https://graph.facebook.com/"+fbid+"?fields=friends.fields(installed,name)&access_token="+fbtoken+'"',
success:function(httpResponse)
{
    listFromFB = JSON.parse(JSON.stringify(httpResponse.data.friends.data));
    console.log("GOT FBLIST");
    for(var item in listFromFB)
    {
        if(listFromFB[item].installed!=null)
        {
            var query = new Parse.Query("User");
                query.notEqualTo("FaceBookId",listFromFB[item].id );
                query.find({
                    success: function(results) 
                    {
                        console.log(results.id);
                        //this is where i change listFromFB[item].installed to user id but i dint get any results from query
                        //response.success(results);
                    },
                        error: function(error) {
                        //response.error("failed to look for users");
                        console.log(error.code);
                    }
                });

        }
    }
        response.success(listFromFB);
    },
    error:function(httpResponse)
    {
    console.log("didnt get it");
    response.error(httpResponse);
    }});
});

The query doesn't seem to work. Can anyone help me with WHY?

I should note that the query itself works if get it in another cloudcode define function.

1 Answer 1

0

You forgot the "Masterkey" bro. Just add this at the very top of your function :

Parse.Cloud.useMasterKey();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.