0

I am trying to figure out if my server can make outbound https request(more specifically port 443) by using cURL, but the code is neither loading any page content nor giving any error.

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
$response = curl_exec($ch);
echo $response;

// close cURL resource, and free up system resources
curl_close($ch);
?>

I am new to the use of cURL, but shouldnt it load the content of google's home page?

0

2 Answers 2

1

to actually get the response you must add:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

don't scrape google, even to test, they actively detect and stop this

Sign up to request clarification or add additional context in comments.

1 Comment

Is there any url that i can use in this purpose to figure out if outward https requests are working or not?
0

If you want to send request to https server,sometimes you also need these two options:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.