PHP - How to fire HTTP get request on a secured URL (HTTPS)?

bob5709

New Member
I am trying to fire a HTTP GET request on a secured URL which asks for username and password. This is fine when I am using that from browser but I am not sure how to do that using PHP.I have tried using the two methods:1) Using Curl as suggested in here: Make a HTTPS request through PHP and get response2) Using the file_get_contents as suggested in here: How to send a GET request from PHP?But the first one didn't give me any response back. And the second one gave me the following error:\[code\]failed to open stream: HTTP request failed\[/code\]And this is my code for the curl:\[code\]$url="https://xxxxx.com";$ch=curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$response = curl_exec($ch);curl_close($ch);echo $response;\[/code\]and for the file_get_contents:\[code\]$url="https://xxxx.com";$response=file_get_contents($url);echo $response;\[/code\]The URL will return a XML response for a API I am testing. Can someone point me to the right direction?Thanks!
 
Back
Top