Jump to content

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


peterhuynh
Go to solution Solved by 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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

 

:(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.