Serge
Serge

Reputation: 6712

curl_exec returns blank with no errors

I make a curl call which seems to go fine.

[http_code] => 200, and curl_errno is 0.

Yet despite the fact there should be an output ([download_content_length] => 102), the curl_exec call doesn't return anything.

define('_WSURL', 'https://mobistar.msgsend.com/mmp/cp3'); // Feel free to try it yourself

$stderr = fopen("err.log", 'w+');
if ($stderr !== false) {
  print "Opened the log file without errors";
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, _WSURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
// curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $stderr);
// curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).DIRECTORY_SEPERATOR.'c00kie.txt'); 

$data = curl_exec($ch);

fclose($stderr);

print_r(curl_getinfo($ch));

print_r($data);

if ($data === false)
{ // Process curl error codes here
    echo('ERROR');
    echo(curl_errno($ch));
} else {
    echo(sprintf('DATA: [%s]', $data));
}
curl_close($ch);

How comes?

Upvotes: 1

Views: 1027

Answers (2)

Serge
Serge

Reputation: 6712

Arg, I'm so stupid sometimes...

The response is a XML and I tried to output it directly in the HTML, but of course it's just considered a set of invalid tags thus display as blank.
I should have taken a closer look to the source code XD

Upvotes: 0

Nadh
Nadh

Reputation: 7253

Returns a response for me.

<?xml version="1.0" encoding="UTF-8"?>
<response code="499" description="The XML Content is Invalid"/>

I suspect you're seeing a blank page in your browser. If it's so, take a look at the page source in the browser, the XML should be there.

Upvotes: 4

Related Questions