Twitter's implementation of OAuth requires a little more work than Facebook.
I would start with Twitter's OAuth Documentation if you're determined to write your own code. I strongly recommend finding a library; there are good libraries out there for almost every language what someone else has already done.