cancel
Showing results for 
Search instead for 
Did you mean: 

No response when I use curl, get reponse when a form

No response when I use curl, get reponse when a form

I am having trouble using curl, when I make the request as a form and click submit I get the response I expect, but when I try to use curl, I get no response at all.

 

Code:

// Get cURL resource
echo 'Starting<br>';
$curl = curl_init();
// Set some options - we are passing in a useragent too here
echo 'Setting Options<br>';
curl_setopt_array($curl, [
	CURLOPT_RETURNTRANSFER => 1,
	CURLOPT_URL => 'http://<url>:85/?script=ConnectionTest',
	CURLOPT_USERAGENT => 'Codular Sample cURL Request'
]);
// Send the request & save response to $resp
echo 'Processing request<br>';
$resp = curl_exec($curl);
// Close request to clear up some resources
echo 'Closing<br>';
curl_close($curl);
echo 'Response = ';
echo $resp;

Output from above:

Starting
Setting Options
Processing request
Closing
Response =

 

So it looks like it is working but no response.

 

This is the form version

<form action="http://<url>:85" method="get" target="_blank">
<input type="hidden" value="ConnectionTest" name="script" />
<input type="submit" value="Submit" />
</form>

 

Response is 'Hi from Ostendo'