ldrrp Posted January 17, 2012 Share Posted January 17, 2012 i been trying to get this code to work but it just wont <? function mtgox_query($path, array $req = array()) { // API settings $key = ''; $secret = ''; // generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems $mt = explode(' ', microtime()); $req['nonce'] = $mt[1].substr($mt[0], 2, 6); // generate the POST data string $post_data = http_build_query($req, '', '&'); // generate the extra headers $headers = array( 'Rest-Key: '.$key, 'Rest-Sign: '.base64_encode(hash_hmac('sha512', $post_data, base64_decode($secret), true)), ); // our curl handle (initialize if required) static $ch = null; if (is_null($ch)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MtGox PHP client; '.php_uname('s').'; PHP/'.phpversion().')'); } curl_setopt($ch, CURLOPT_URL, 'https://mtgox.com/api/'.$path); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // run the query $res = curl_exec($ch); if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch)); $dec = json_decode($res, true); if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists'); return $dec; } // example 1: get infos about the account, plus the list of rights we have access to var_dump(mtgox_query('0/info.php')); ?> Fatal error: Call to undefined function curl_init() in Z:\Documents\htdocs\trade\mtgox.php on line 23 Quote Link to comment https://forums.phpfreaks.com/topic/255188-curl_init/ Share on other sites More sharing options...
ldrrp Posted January 17, 2012 Author Share Posted January 17, 2012 Fatal error: Uncaught exception 'Exception' with message 'Could not get reply: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in Z:\Documents\htdocs\trade\mtgox.php:33 Stack trace: #0 Z:\Documents\htdocs\trade\mtgox.php(40): mtgox_query('0/info.php') #1 {main} thrown in Z:\Documents\htdocs\trade\mtgox.php on line 33 Quote Link to comment https://forums.phpfreaks.com/topic/255188-curl_init/#findComment-1308399 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.