Jump to content

I get "bool(false)" when I run this script. It works for someone else tho?


peterhuynh

Recommended Posts

This is the script I'm running:

<?php
$ch = curl_init('https://www.cointrader.net/api4/stats/high/BTCUSD');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response); 
?>

This is the response I get:

bool(false)

I emailed the API guy at that website for help. He ran the script and gets the proper results. Any tips?

 

Thanks! :D

This is because curl is returning this error message (returned from calling curl_error)

 

SSL certificate problem: unable to get local issuer certificate

When you use https:// urls curl needs to verify the security certificate. By default curl does not do this.

 

You can set the CURLOPT_SSL_VERIFYPEER option to false to get around this. But that is not the correct solution. The correct way is explained here

This is because curl is returning this error message (returned from calling curl_error)

When you use https:// urls curl needs to verify the security certificate. By default curl does not do this.

 

You can set the CURLOPT_SSL_VERIFYPEER option to false to get around this. But that is not the correct solution. The correct way is explained here

 

I set it to FALSE:

$ch = curl_init('https://www.cointrader.net/api4/stats/high/BTCCAD');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response); 

It isn't sensitive data, so the improper way is fine. However, it still outputs bool(false).

 

:(

Works fine for me. Use curl_error to see why you are getting false

 

I get this message:

 

"Curl error: SSL: certificate subject name 'incapsula.com' does not match target host name 'www.cointrader.net'bool(false)"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.