66 lines
2.2 KiB
PHP
66 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\Cookie\CookieJar;
|
|
use function GuzzleHttp\json_decode;
|
|
|
|
|
|
class ThreeCommasController extends Controller
|
|
{
|
|
private $baseUrl = 'https://3commas.io';
|
|
private $api_version = '/public/api/ver1/';
|
|
private $api_key = 'fd2465a6fa0e455986ef99a51dea14c759bf2feb8f5344558715b1176a3680e8';
|
|
private $api_secret = '7a43c6de51fc9d4d10f1889bc0bd816d1da63d24c4b0ef357f35e4eb95c5f5e6fef355b891cee3960d7cfc872f328c38906ac17a7152610098eb14940f29cb5643c58c09a7de5fa63859ffe1baedf01ba0c3fa3f30757f33bf5d5f7f2e22e3539f70109e';
|
|
|
|
|
|
public function getTrades(){
|
|
$end_point = 'smart_trades';
|
|
$url = $this->baseUrl . $this->api_version . $end_point;
|
|
|
|
$params = [
|
|
'api_key' => $this->api_key,
|
|
'secret' => $this->api_secret,
|
|
'scope' => 'active',
|
|
'limit' => 50
|
|
];
|
|
$query = http_build_query($params);
|
|
$signature = hash_hmac('sha256', $this->api_version . $end_point . '?' . $query, $this->api_secret);
|
|
|
|
$client = new Client([
|
|
'headers' => [
|
|
'Content-Type' => 'application/json',
|
|
'APIKEY' => $this->api_key,
|
|
'Signature' => $signature
|
|
],
|
|
]);
|
|
$response = $client->request('GET', $url . '?' . $query);
|
|
$data = json_decode($response->getBody());
|
|
return $data;
|
|
}
|
|
|
|
public function getBalance(){
|
|
$end_point = 'accounts';
|
|
$url = $this->baseUrl . $this->api_version . $end_point;
|
|
|
|
$params = [
|
|
'api_key' => $this->api_key,
|
|
'secret' => $this->api_secret,
|
|
];
|
|
$query = http_build_query($params);
|
|
$signature = hash_hmac('sha256', $this->api_version . $end_point . '?' . $query, $this->api_secret);
|
|
|
|
$client = new Client([
|
|
'headers' => [
|
|
'Content-Type' => 'application/json',
|
|
'APIKEY' => $this->api_key,
|
|
'Signature' => $signature
|
|
],
|
|
]);
|
|
$response = $client->request('GET', $url . '?' . $query);
|
|
$data = json_decode($response->getBody());
|
|
return $data;
|
|
}
|
|
} |