Dose the code work on you side? If so, I may need start investigate my network problem instead of code...
I got this "403 {"result":"error","error":"Identification required to access private API","token":"login_required"}" when try https://mtgox.com/api/1/generic/private/orders using POST.