Jump to content

brucegregory

Members
  • Posts

    22
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

brucegregory's Achievements

Member

Member (2/5)

0

Reputation

  1. I can retrieve my account number correctly, but the other variables will not work with the same notation.
  2. Notice: Array to string conversion in C:\xampp\htdocs\bitcoin\mtgox.php on line 100 Notice: Undefined index: BTC in C:\xampp\htdocs\bitcoin\mtgox.php on line 100 USDS: Array BTCS: Sorrry. Im not new to PHP, but I have no idea how to do this and Google isnt helping me much like it usually does. Thank You
  3. I tried and I get errors everytime. Can you give me another hint? Please
  4. So now I have a return from an API with more than one array and I need to decode it to PHP variables again. <?php function cryptoxchange_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( 'cryptokey: '.$key, 'cryptopayload: '.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://cryptoxchange.com/api/v0/account/balance/?stamp=$mt'.$path); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 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')); // old api (get funds) echo 'MtGox'; echo '<br/>'; var_dump(cryptoxchange_query('')); //$values = (cryptoxchange_query('')); //echo "USDS: ".$values['Balance'].' BTCS: '.$values['BTC']; // trade example // var_dump(mtgox_query('0/buyBTC.php', array('amount' => 1, 'price' => 15)));\ ?> Output: array(5) { ["AccountNumber"]=> string(18) "xxxxxxxxxxx" ["Balance"]=> array(4) { ["USD"]=> string(11) "47.42805318" ["AUD"]=> string(10) "0.00000000" ["BTC"]=> string(10) "7.15424820" ["NMC"]=> string(10) "0.00000000" } ["ReturnCodes"]=> int(1) ["err"]=> string(0) "" ["stamp"]=> string(3) "$mt" } Sorry for all the questions, Than You!
  5. Thank You so much! That worked exactly as exspected.
  6. <?php function mtgox_query($path, array $req = array()) { // API settings $key = '7583cda31885'; $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); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 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')); // old api (get funds) var_dump(mtgox_query('0/getFunds.php')); // trade example // var_dump(mtgox_query('0/buyBTC.php', array('amount' => 1, 'price' => 15)));\ ?> OutPut : array(2) { ["usds"]=> string( "37.94073" ["btcs"]=> string(10) "6.44987703" } How do I maek 'usds' and 'btcs' into variables so I can echo $usds; Thank you so much for the help!
  7. I am developing a purchase ordering system for a factory. A new feature is to allow someone to duplicate a purchase order. I have divided the system into two parts: purchase order, and purchase order items. I have made it where someone can duplicate the purchase order, but I cannot figure out how to duplicate the items because their are usually more than 1 item per purchase order, but sometimes when they are duplicated he only wants some of the items. I am not expecting you to code this for me, I just need a general flow chart. Please Help, Thanks
  8. I have made a production schedule in PHP and I need to seperate the dates by every week. Starting with Sunday and ending with Saturday. Is this possible? Thanks!
  9. I know their is an error somewhere in this code, but I have looked for hours and found a few syntax errors. My code will not give back any errors, it will just simply not insert into the database. If you see anything please let me know. Thanks! <?php session_start(); $username=$_SESSION['username']; if($username==''){ header("location:http://192.168.2.2/login.php"); } $con = mysql_connect("localhost","root","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); mysql_query("INSERT INTO quote_sheet (customer, attn, phone, fax, date, part, description, material, shipping, exceptions, tool_deliver_qty, tool_delivery_price, production_delivery_qty, production_delivery_price, other01, other02, other03, quoted_by, grams, surf_area, tons, density, lbs_min_parts, vsp1, lbs_mil_min, percent1, percent3, vsp2, ton_press2, pcs_hour1, pcs_hour2, sintered1, sintered2, sec_1, sec_2, sec_3, sec_4, sec_5, sec_6, sec_7, sec_8, set_up_charges, manu_costs, comm, tool, spec, lbs_mil_min2 ) VALUES ('$_POST[customer]','$_POST[attn]','$_POST[phone]', '$_POST[fax]', '$_POST[date]','$_POST[part]', '$_POST[description]', '$_POST[material]','$_POST[shipping]', '$_POST[exceptions]', '$_POST[tool_delivery_qty]','$_POST[tool_delivery_price]', '$_POST[production_delivery_qty]', '$_POST[production_delivery_price]','$_POST[other01]', '$_POST[other02]', '$_POST[other03]','$_POST[quoted_by]', '$_POST[grams]', '$_POST[surf_area]','$_POST[tons]', '$_POST[density]', '$_POST[lbs_mil_parts]','$_POST[vsp1]', '$_POST[lbs_mil_min]', '$_POST[percent1]', '$_POST[percent3]', '$_POST[vsp2]','$_POST[ton_press2]', '$_POST[pcs_hour2]', '$_POST[sintered1]','$_POST[sintered2]', '$_POST[sec_1]', '$_POST[sec_2]','$_POST[sec_3]', '$_POST[sec_4]', '$_POST[sec_5]','$_POST[sec_6]', '$_POST[sec_7]', '$_POST[sec_8]','$_POST[set_up_charges]', '$_POST[manu_costs]', '$_POST[comm]', '$_POST[tool]', '$_POST[spec]', '$_POST[lbs_mil_min2]'"); mysql_close($con); echo 'Quote Successfully Inserted'; ?>
  10. Thank you for your help. I have fix my error with your advice!
  11. I have a very populated MYSQL database and I need to make it so that when a input field in a form is left blank it has N/A in the database. So my solution is to change all of the default fields to N/A, but I have well over 500 rows. If I change this will it change my already populated rows with data in them? Thanks
  12. I have a description field for a form and when it goes over 30 characters, the table row stretches into other fields. I think if I can make PHP echo a <br/> after 30 characters it may work... but how? Thanks in advance, Bruce
  13. Is it possible to put a multiplication problem in the mysql "default value" field? In my script I need to take the unit amount * quantity, I know how to do this in php, but can I just put my equation in the "default value" field in MYSQL and make it equal to another field?... Like excell? Thanks
  14. one of the values needs to be purchase_order_date, not purchase_order.
×
×
  • 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.