I would recommend you to start with:
https://developers.facebook.com/[
^] and see how they do it. Once you understand what they do, try to adapt it to your needs.
When you get a problem you don't know how to solve
but at least you tried it, then come back and ask for something concrete with a snippet of the code giving problems
Sorry if this is not the answer you were looking for. But your question is a bit too wide to be answered at the "Quick" Answers. It is better and you get faster help if you make 10 concrete questions about concrete problems, than a big question about a "how-to guide"