peterhuynh Posted February 22, 2015 Share Posted February 22, 2015 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! Link to comment https://forums.phpfreaks.com/topic/294792-i-get-boolfalse-when-i-run-this-script-it-works-for-someone-else-tho/ Share on other sites More sharing options...
Ch0cu3r Posted February 22, 2015 Share Posted February 22, 2015 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 https://forums.phpfreaks.com/topic/294792-i-get-boolfalse-when-i-run-this-script-it-works-for-someone-else-tho/#findComment-1506403 Share on other sites More sharing options...
peterhuynh Posted February 22, 2015 Author Share Posted February 22, 2015 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 https://forums.phpfreaks.com/topic/294792-i-get-boolfalse-when-i-run-this-script-it-works-for-someone-else-tho/#findComment-1506440 Share on other sites More sharing options...
Ch0cu3r Posted February 22, 2015 Share Posted February 22, 2015 Works fine for me. Use curl_error to see why you are getting false Link to comment https://forums.phpfreaks.com/topic/294792-i-get-boolfalse-when-i-run-this-script-it-works-for-someone-else-tho/#findComment-1506449 Share on other sites More sharing options...
peterhuynh Posted February 22, 2015 Author Share Posted February 22, 2015 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)" Link to comment https://forums.phpfreaks.com/topic/294792-i-get-boolfalse-when-i-run-this-script-it-works-for-someone-else-tho/#findComment-1506451 Share on other sites More sharing options...
peterhuynh Posted February 22, 2015 Author Share Posted February 22, 2015 I used this and it works now. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); Thanks for the help, Ch0cu3r Link to comment https://forums.phpfreaks.com/topic/294792-i-get-boolfalse-when-i-run-this-script-it-works-for-someone-else-tho/#findComment-1506465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.