How to query Blackberry contact with UID? - blackberry

I want to search UID in the native Contacts. I have the UID of a particular Contact, now I want to update all those Contacts that match this UID which I have in my DB. My main aim is to stop the duplication of Contacts which I insert. Can anyone help me to do this?

Hey got the Answers of my own question.. Thanks for all your efforts. By using your UID no. you can just call this Method
contact = (BlackBerryContact) contactsList.getByUID(uid, 1);
Pass your uid and do the same as you are doing for Retrieving the contact with Phone number.

Related

Twitter request does not return all followers

I am using TwitterKit in orther to show my followers list. So I am using this GET request:
https://dev.twitter.com/rest/reference/get/followers/list
The problem is it only returns a list of 20 followers. Does anybody of you know how to manage this problem ? I need it to return all of them.
Any idea ?
Thank you very much
From reading the documentation, this call returns a lost of followers. The default number of the list of followers it return is 20 thus you're getting the 20 contacts only. This API have a parameter called count where you can specify the number of followers you want to retrieve, the maximum is 200.
However there is a call that can reurn all the IDs for the followers: https://dev.twitter.com/rest/reference/get/followers/ids
This will return all followers IDs up to 5000 ID, however it will send ID only and not all the information of the followers. here is the documentation for this API: https://dev.twitter.com/rest/reference/get/followers/ids
Hope this helps!

Friends list on Firebase

So far on my firebase I have something like:
Users
293840ajldkjfas0d9
username: Jill
09283049802930laks
username: Jack
I'm basically going to just have a text field and when someone hits the "add" button, a search through firebase gets done to make sure that username exists, and go from there on connecting the two as friends.
My question is I'm not understanding how I would sort through my data if it's structured like this? I might be totally missing something but is there a way to search through what I have now and say "Go to my users reference, go to through each UID and pull out the username and see if it matches what the user put in the text field, and if so grab the UID connected to the username"?
I'm almost thinking I need to have an entirely separate branch? that I have in addition to what I already have that looks like
Usernames
Jack
09283049802930laks
Jill
lasdjf9j09u90320j09
Which would then allow me to just go to my usernames and go through and check through the values inside that (jack/Jill) and then if it exists then pull that uid out of the username.
1) Do I need both of these branches or is there a way to accomplish what I'm trying to do with just my first?
2) How exactly do I check for that match? Would a query be used or just checking for Null somehow?
3) Is this even the right way to go about doing this? I've found little to no information on friends lists online so this is just all an assumption.
Any help is appreciated!
Using the below structure, you can check if a user exists with a single query. Here's all the code you need:
This is the db structure:
Users
293840ajldkjfas0d9
username: Jill
09283049802930laks
username: Jack
Here is the code:
var usernameEntered = self.usernameField.text!
var databaseReferenceQuery = self.ref.child("users").queryOrderedByChild("username").queryEqualToValue(usernameEntered).observeSingleEventOfType(.Value, withBlock: { (snapshot) in
if ( snapshot.value is NSNull ) {
// No user :(
} else {
// User exists! Do stuff!
}
}, withCancelBlock: { (error) in
// An error occurred
})
Once you have established a user exists, I can think of a few ways to go about getting the uid. The key is to find a place where both the uid and the username are stored.
Option 1:
Create another branch in the users db structure that stores the uid.
Set up this branch when the user is signed up.
Option 2:
Store the username as the displayName in the standard auth system and get the uid from there.
Set this up when the user signs up.
That's up to you.
Response to comments:
You can simply retrieve the key of the user in the table, however this will not allow access to any auth features and will not allow user accounts to be edited in any way.
Examples of situations where this can be useful include updating user info, deleting accounts etc.

remove specific record from array of records all in rails

I am implementing search functionality in rails. When i search for users, the logged in user who is searching also comes in search. I want to avoid it.
This is in my search_method in controller
#matchedUsers = InUser.where("first_name like ?", "%#{params[:searchfnameInput]}%")
And i have user id in session[:user_id]. I want to exclude the record having id==session[:user_id] from #matchedUsers?
Thanks and Regards
Add another where clause to your query:
#matchedUsers = InUser.where("id<>?", current_user.id).where("first_name like ?", "%#{params[:searchfnameInput]}%")
The "id<>?" says "exclude the user with this ID".

How to select all of a unique attribute

I would like to find all the Records that have unique email addresses. I am trying to perform this :
#uniq_referrals = []
CardReferral.all.select{|a| #uniq_referrals << a.email}
#referral_count = #uniq_referrals.uniq.each{|a|CardReferral.find_by_email(a)}
But I would like to do it in a single call. Is that possible?
You can use:
CardReferral.select("distinct(email), other_field_you_need")
where other_field_you_need it's a list of field name you need to use from the objects you get from ActiveRecord.
To get the count of unique email record you can use:
CardReferral.count("distinct(email)")
I would like to find all the Records that have unique email addresses. I am trying to perform this :
#uniq_referrals = []
CardReferral.all.select{|a| #uniq_referrals << a.email}
#referral_count = #uniq_referrals.uniq.each{|a|CardReferral.find_by_email(a)}
But I would like to do it in a single call. Is that possible?
I think that it would help you:
Model.group("email")
when we group all the record by email id then you will find all the record that have uniq email. if some record have same id then you will get first record.
please prefer to image for more understanding.
If you could not get yet, then i will explain elaborate more.

Find friends using an application

How to programmatically find which of my friends are using my application using Mogli or Facebooker2.
If the only way is to use FQL can someone provide an example?
I think the code bellow is able to find the
select uid, name, is_app_user from user where uid in (select uid2 from friend where uid1=me()) and is_app_user=1
Just tested:
https://api.facebook.com/method/fql.query?query=select+uid%2C+name%2C+is_app_user+from+user+where+uid+in+%28select+uid2+from+friend+where+uid1%3Dme%28%29%29+and+is_app_user%3D1%0A
&access_token=YOUR_ACCESS_TOKEN
&format=json
And is returning the correct results so FQL is actually working!

Resources