PHP fopen(),file_get_contents(),cURL()的问题

Im trying to connect to a web service, when I connect to it using a form, explicitly declaring the URL in form action="{{ URL of web service }} + parameters", Im able to connect and use the web service. However when I use fopen(), file_get_contents() or cURL I get authentication error.

I have already tried declaring the username and password(username:password) in fopen() and doing it also in cURL and using the different authentication method in cURL(basic etc). and still no luck.

I really would love to have an explanation for this behavior.