php:post to a url need authentication

weltkrieg

New Member
I need to do a post to a url which need to be authenticated first, in C#, i can do this\[code\] HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.Credentials = new NetworkCredential(username, password); myRequest.PreAuthenticate = true; Stream newStream = myRequest.GetRequestStream(); newStream.Close(); // Get response try { HttpWebResponse response = (HttpWebResponse)myRequest.GetResponse(); return response.StatusDescription; // some other code } catch (Exception ex) { return ex.Message; }\[/code\]how to do this in php?
 
Back
Top