How to get userID from contact list?

Thank you for your answer! Could you give me a code example on how I could use those APIs in practice. And where should I put the code in this situation?