3commasWatch/app/Http/Controllers/ThreeCommasController.php

71 lines
2.1 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
{
public function getTrades(){
$baseUrl = 'https://3commas.io';
$api_version = '/public/api/ver1/';
$end_point = 'smart_trades';
$url = $baseUrl . $api_version . $end_point;
$api_key = 'fd2465a6fa0e455986ef99a51dea14c759bf2feb8f5344558715b1176a3680e8';
$api_secret = '7a43c6de51fc9d4d10f1889bc0bd816d1da63d24c4b0ef357f35e4eb95c5f5e6fef355b891cee3960d7cfc872f328c38906ac17a7152610098eb14940f29cb5643c58c09a7de5fa63859ffe1baedf01ba0c3fa3f30757f33bf5d5f7f2e22e3539f70109e';
$params = [
'api_key' => $api_key,
'secret' => $api_secret,
'scope' => 'active',
'limit' => 50
];
$query = http_build_query($params);
$signature = hash_hmac('sha256', $api_version . $end_point . '?' . $query, $api_secret);
$client = new Client([
'headers' => [
'Content-Type' => 'application/json',
'APIKEY' => $api_key,
'Signature' => $signature
],
]);
$response = $client->request('GET', $url . '?' . $query);
$data = json_decode($response->getBody());
return $data;
}
public function getSignals(){
// Initialize the client
$api = new Client([
'base_uri' => 'https://app.signalprofits.com/',
'cookies' => true, // You have to have cookies turned on for this API to work
]);
// Login
$api->post('app/login', [
'form_params' => [
'identity' => 'john@eutrading.co.uk', // use your actual username
'password' => 'l0uis0404!', // use your actual password
],
]);
// Fetch
$response = $api->get('app/login');
// and decode some data
$boxscore = $response->getBody();
// And logout
$test = $api->get('wp-admin/admin-ajax.php?action=get_signals&limit=100');
$test2 = $test->getBody();
// $test2 = json_decode($test->getBody());
return $test2;
}
}