I\'m try to do this request on php, for download the last source from my Bitbucket private repository:
curl --digest --user user:pass https://bitbucket.org/u
I've given it the customary "20 minute tinker" and I'll be damned, working with CURL and my OSX HTTP Client this does not seem to want to budge, and I've worked successfully with HTTP Digest and Curl in the past.
One suggestion: if the command line is working then why not use the command? Does your production server support exec()?