add/search for friends

So I have started working on the friends function of cloud and I am abit confused as of how it is supposed to work.

With the friends.add( ID ), what is the ID here? is it the e-mail or the display name? and it seems that whatever I put in a “friend” gets added… no checking if that person exists or if the name is valid. How do you check if the info typed in is a registered user?

And when searching for a user,  how do you check if a user is playing the same game? As I have understood it the users are global, so how do you only display those that are playing the same game that you are? is it something one can add to the keyword when searching? or do one have to check something in the user info returned?

sorry if these things are basic and should be clear but any help is greatly appreciated :slight_smile:

and also, trying to delete these imaginary friends I managed to add… but when I do I get the error “Friend id is not sent with request”. I have tried both with the field called “_id” and “friend_id”… but none of these are working. So how do I go about finding the correct id to send to the remove function?

any news on this or am I the only one having this problem? :slight_smile:

ok, so still not getting this to work. The friends.find( keyword ) works good. I can put in a keyword and it will find alot of users so that is ok. But from that info, what goes into the friends.add( friendID ) and friends.remove( friendID ). More spesific, which field is to be used as the friendID from the respons of friends.fiend( keyword )? I feel like I have tried everything but must be missing something if this is to work. Always get the “Friend id is not sent with request” error and cant remove the “fake” users/friends from my list.

The response list from friends.find() when seraching for my own user as example:

{

“_id”:“517b81acc58f8ae5a8000002”,

“achievements”:null,

“activated_at”:“2013-04-27T07:57:51Z”,

“active”:true,

“city”:null,

“country”:null,

“created_at”:“2013-04-27T07:43:40+00:00”,

“facebook_enabled”:null,

“facebook_id”:null,

“first_name”:null,

“game_ids”:[“5177818d2bef5a4092000002”],

“last_device_used”:null,

“last_game_played”:null,

“last_login”:null,

“last_name”:null,

“location_lat”:null,

“long_coords”:null,

“notification_channel_ids”:[],

“points”:0,

“profile_picture_content_type”:null,

“profile_picture_file_name”:null,

“profile_picture_file_size”:null,

“profile_picture_updated_at”:null,

“remember_token”:null,

“remember_token_expires_at”:null,

“reset_code”:null,

“signed_up_from_facebook”:false,

“twitter_access_secret”:null,

“twitter_enabled”:null,

“twitter_id”:null,

“updated_at”:“2013-04-27T07:57:51+00:00”,

“username”:“borgb”,

“photo”:null

}

what here should be used for adding a friend?

Hi,

You need to pass “_id”:“517b81acc58f8ae5a8000002”, in the call.

-Mohamed

ok, so doing that will create a user with this info when friends.getAll() is called:

{

 [updated_at] => “2013-05-01T10:13:02+00:00”

[_id] => “5180eaae2bef5ae43600000e”

[friend_id] => “517b81acc58f8ae5a8000002”

[created_at] => “2013-05-01T10:13:02+00:00”

[user_id] => “517b81acc58f8ae5a8000002”

 }

to remove this user from my list, what do I need to pass into friends.remove( friendID)?

Hi,

So the idea is now that user is a ‘friend’ so to remove them, you pass :

[friend_id] => “517b81acc58f8ae5a8000002”

Thanks

-Mohamed

thats when I get the “Friend id is not sent with request” error

granted some of the users on my list isnt real users because they were added by just putting any name into the friend.add() function. but they all get the same info in them. But they wont disapere from the list and all get the same error.

this is the output: (I xed  the auth_tokens)

Corona Cloud: – DELETE Call —

Corona Cloud: Delete URL: https://api.coronalabs.com

Corona Cloud: Delete Path: friends.json

Corona Cloud: Delete Parameters: auth_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&user_id=5180eaae2bef5ae43600000e

Corona Cloud: ----------------

Corona Cloud: 

Delete Request: https://api.coronalabs.com/friends.json?auth_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&user_id=5180eaae2bef5ae43600000e

Corona Cloud: Friend Deleted: Friend id is not sent with request

Friends:     Friend id is not sent with request

Ok, I see why :slight_smile:

It seems that for some reason the wrong parameter is being sent; it looks like you are sending user_id, instead it should be friend_id.

So your call should look like this:

https://api.coronalabs.com/friends.json?auth_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&friend_id=5180eaae2bef5ae43600000e

Thanks

-Mohamed

no, its just that the user_id is the same as friend_id in that instance since the user is me. I am my own best friend I guess you could say :smiley: but the results are the same with all other “friends” I have on the list. Sorry if I was abit confusing with the example I chose to delete.

thanks for the quick replys by the way :slight_smile:

Hehe :slight_smile:

What I was pointing out is not the actually value of the ID, but rather the parameter name.

In the command you showed you posted it has the parameter ‘user_id’, thats incorrect, you need to pass ‘friend_id’.

Even if you are adding yourself, you still need to use friend_id. The idea is now these users in your friend lists are ‘friends’, so to identify them you need to pass ‘friend_id’.

You see what I mean?

-Mohamed

Just to follow up, it looks like the initial corona-cloud-core.lua file is passing the wrong parameter name.

I would suggest you can either:

  1. update to the new lib https://github.com/coronalabs/framework-cloud

or

  1. you can fix the current one;

Line (1051) 

Change from: params = params…"&user_id="…friendID  to: params = params…"&friend_id="…friendID

Thanks

-Mohamed

aha, that did the trick indeed :slight_smile: thanks alot!

also, I see now that I need to get the userprofile of each one in order to get their username… would it be possible to add the username to the information retrived by friends.getAll()? so we dont have to go and do an extra operation in order to get the username? Or is there an easier way than cloud.getProfile( friend_id ) -> then pick out the username from the event.response ? Just would seem logical to display friends by names and not ids :slight_smile:

thanks again for the help!

I’ve added this request to be reviewed by the team.

Thanks

-Mohamed

awesome, thanks :slight_smile:

and also, trying to delete these imaginary friends I managed to add… but when I do I get the error “Friend id is not sent with request”. I have tried both with the field called “_id” and “friend_id”… but none of these are working. So how do I go about finding the correct id to send to the remove function?

any news on this or am I the only one having this problem? :slight_smile:

ok, so still not getting this to work. The friends.find( keyword ) works good. I can put in a keyword and it will find alot of users so that is ok. But from that info, what goes into the friends.add( friendID ) and friends.remove( friendID ). More spesific, which field is to be used as the friendID from the respons of friends.fiend( keyword )? I feel like I have tried everything but must be missing something if this is to work. Always get the “Friend id is not sent with request” error and cant remove the “fake” users/friends from my list.

The response list from friends.find() when seraching for my own user as example:

{

“_id”:“517b81acc58f8ae5a8000002”,

“achievements”:null,

“activated_at”:“2013-04-27T07:57:51Z”,

“active”:true,

“city”:null,

“country”:null,

“created_at”:“2013-04-27T07:43:40+00:00”,

“facebook_enabled”:null,

“facebook_id”:null,

“first_name”:null,

“game_ids”:[“5177818d2bef5a4092000002”],

“last_device_used”:null,

“last_game_played”:null,

“last_login”:null,

“last_name”:null,

“location_lat”:null,

“long_coords”:null,

“notification_channel_ids”:[],

“points”:0,

“profile_picture_content_type”:null,

“profile_picture_file_name”:null,

“profile_picture_file_size”:null,

“profile_picture_updated_at”:null,

“remember_token”:null,

“remember_token_expires_at”:null,

“reset_code”:null,

“signed_up_from_facebook”:false,

“twitter_access_secret”:null,

“twitter_enabled”:null,

“twitter_id”:null,

“updated_at”:“2013-04-27T07:57:51+00:00”,

“username”:“borgb”,

“photo”:null

}

what here should be used for adding a friend?

Hi,

You need to pass “_id”:“517b81acc58f8ae5a8000002”, in the call.

-Mohamed