I personally use cURL, it handles all the things like proxy redirects and everythign for you