-
Notifications
You must be signed in to change notification settings - Fork 0
/
createData.php
35 lines (32 loc) · 1.13 KB
/
createData.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
if(isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']=="localhost"){
$url = "http://localhost/cryptboard/callExchanges.php";
}else{
$url = "http://nammabagalkot.in/cryptboard/callExchanges.php";
}
date_default_timezone_set('Asia/Kolkata');
$date = date('m_d_Y', time());
$time_stamp = date('m/d/Y H:i:s', time());
$responseData = file_get_contents($url);
$responseData = json_decode($responseData);
foreach ($responseData as $key => $value) {
// var_dump($responseData);
$fileToday = "data/" . $date ."_". $value->name."_price.txt";
if(strtolower($value->name)=="koinex"){
//btc,bch,eth,xrp
$writeData = $time_stamp . "," .$value->buy. ",".$value->bch->buy.",".$value->eth->buy.",".$value->xrp->buy. "\n";
}else if(($value->name)=="global"){
// var_dump($value);
$writeData = $time_stamp . "," .$value->buyUSD. "," .$value->buy. "\n";
}else{
$writeData = $time_stamp . "," . $value->buy ."\n";
}
if (file_exists($fileToday)) {
file_put_contents($fileToday, $writeData, FILE_APPEND);
} else {
$myfile = fopen($fileToday, "w") or die("Unable to open file!");
fwrite($myfile, $writeData);
fclose($myfile);
}
}
?>