Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('Bitfinex.php');
- include "vendor/NotORM.php";
- // database and NotORM
- $dsn = 'mysql:dbname=f97941;host=c108um.forpsi.com';
- $user = 'f97941';
- $password = 'EAV9MAB';
- $pdo = new PDO($dsn, $user, $password);
- $db = new NotORM($pdo);
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- // bitfinex API
- $api_key = 'xxxxxxxxxx';
- $api_secret = 'yyyyyyyyyy';
- $bfx = new Bitfinex($api_key, $api_secret);
- // main code
- $currency_code_from = "NEO";
- $currency_code_to = "BTC";
- $current_datetime = "";
- $mid = 0;
- $bid = 0;
- $ask = 0;
- $last_price = 0;
- $low = 0;
- $high = 0;
- $volume = 0;
- $return_json = $bfx->get_ticker($currency_code_from.$currency_code_to);
- foreach ($return_json as $klic => $hodnota)
- {
- switch ($klic)
- {
- case "timestamp":
- $current_datetime = date('Y-m-d H:i:s', $hodnota); // '1000-01-01 00:00:00'
- break;
- case "mid":
- $mid = $hodnota;
- break;
- case "bid":
- $bid = $hodnota;
- break;
- case "ask":
- $ask = $hodnota;
- break;
- case "last_price":
- $last_price = $hodnota;
- break;
- case "low":
- $low = $hodnota;
- break;
- case "high":
- $high = $hodnota;
- break;
- case "volume":
- $volume = $hodnota;
- break;
- }
- }
- print $sql_insert = "insert into exchange_rate_bitfinex values('".$currency_code_from."','".$currency_code_to."','".$current_datetime."',".$mid.",".$bid.",".$ask.",".$last_price.",".$low.",".$high.",".$volume.")";
- $db->exchange_rate_bitfinex()->insert( [ $currency_code_from, $currency_code_to, $current_datetime, $mid, $bid, $ask, $last_price, $low, $high, $volume ] );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement