diff --git a/app/Console/Commands/Grapper/Logifuture.php b/app/Console/Commands/Grapper/Logifuture.php index bc01e6da..d642fede 100644 --- a/app/Console/Commands/Grapper/Logifuture.php +++ b/app/Console/Commands/Grapper/Logifuture.php @@ -2,10 +2,10 @@ namespace App\Console\Commands\Grapper; -use App\Console\Commands\Grapper\Logifuture\Auth; -use App\Console\Commands\Grapper\Logifuture\BaseUrl; +use App\Console\Commands\Grapper\Logifuture\Authentication; use App\Console\Commands\Grapper\Logifuture\Basketball; use App\Console\Commands\Grapper\Logifuture\Icehockey; +use App\Console\Commands\Grapper\Logifuture\LogifutureData; use App\Console\Commands\Grapper\Logifuture\MapEvent; use App\Console\Commands\Grapper\Logifuture\Soccer; use App\Console\Commands\Grapper\Logifuture\Tennis; @@ -19,10 +19,25 @@ use App\Utilities\Notice; class Logifuture { + public static $auth_header = []; + + public static $base_url = ''; + public static function switch() { $debug = Nuh::$options['d'] ?? 0; + switch (Nuh::$options['provider_id']) { + case 5: + Nuh::$options['bookmaker_id'] = 35; + self::$base_url = 'https://external-api.bet9ja.com/external'; + break; + case 6: + Nuh::$options['bookmaker_id'] = 36; + self::$base_url = 'https://external-api.yajuego.co/external'; + break; + } + $_elements = LoadElements::load(Nuh::$options['provider_id'], true); $_groups = LoadGroups::load(Nuh::$options['provider_id'], true); @@ -35,50 +50,11 @@ class Logifuture Notice::note(Nuh::$options['provider']['name'].' '.Nuh::$options['sport']['name'], 'g'); } - switch (Nuh::$options['provider_id']) { - case 5: - Nuh::$options['bookmaker_id'] = 35; - break; - case 6: - Nuh::$options['bookmaker_id'] = 36; - break; - } + Authentication::authenticate(); - // https://external-api.bet9ja.com/external/v1/matches?sport_id=1 - // https://external-api.bet9ja.com/external + foreach ($sportmap as $logifuture_sport_id => $sport_id) { - $data = Auth::exe(); - - $header = []; - $header[] = 'Authorization: Bearer '.$data['token']; - $header[] = 'accept: application/json'; - $header[] = 'content-type: application/json'; - - foreach ($sportmap as $client_sport_id => $sport_id) { - $post_fields = [ - 'url' => BaseUrl::get().'/v1/matches?sportId='.$client_sport_id, - 'header' => json_encode($header), - ]; - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - - if (config('env.app_env') == 'local') { - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); - curl_setopt($ch, CURLOPT_URL, 'https://proxydb1.nuhodds.com/logifuture.php'); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx', - ]); - } else { - curl_setopt($ch, CURLOPT_HTTPHEADER, $header); - } - - $file = curl_exec($ch); - - $matches = json_decode($file, 1); + $matches = LogifutureData::load($logifuture_sport_id); if (! isset($matches['error'])) { diff --git a/app/Console/Commands/Grapper/Logifuture/Authentication.php b/app/Console/Commands/Grapper/Logifuture/Authentication.php new file mode 100644 index 00000000..acc8b5c6 --- /dev/null +++ b/app/Console/Commands/Grapper/Logifuture/Authentication.php @@ -0,0 +1,76 @@ + $url, 'password' => config('env.logifuture_token')]); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx', + ]); + } else { + + /************************************************* + * DIRECT + *************************************************/ + + if ($debug) { + Notice::note('AUTH from PRODUCTION'.PHP_EOL.$url, 'r'); + } + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ + 'username' => 'nuhodds', + 'password' => self::$password, + ])); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'accept: application/json', + 'content-type: application/json', + ]); + } + + $file = curl_exec($ch); + $data = json_decode($file, true); + + $header = []; + $header[] = 'Authorization: Bearer '.$data['token']; + $header[] = 'accept: application/json'; + $header[] = 'content-type: application/json'; + + Logifuture::$auth_header = $header; + } +} diff --git a/app/Console/Commands/Grapper/Logifuture/BaseUrl.php b/app/Console/Commands/Grapper/Logifuture/BaseUrl.php deleted file mode 100644 index 8e8d9d0e..00000000 --- a/app/Console/Commands/Grapper/Logifuture/BaseUrl.php +++ /dev/null @@ -1,36 +0,0 @@ - $url, - 'password' => self::$password, + 'header' => json_encode(Logifuture::$auth_header), ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx', ]); } else { + + /************************************************* + * DIRECT + *************************************************/ + + if ($debug) { + Notice::note('AUTH from PRODUCTION'.PHP_EOL.$url, 'r'); + } + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); @@ -46,8 +65,8 @@ class Auth } $file = curl_exec($ch); - $data = json_decode($file, true); + dd($file); - return $data; + return json_decode($file, true); } } diff --git a/config/env.php b/config/env.php index 0254c9e3..17ce2fdf 100644 --- a/config/env.php +++ b/config/env.php @@ -5,7 +5,8 @@ */ return [ 'app_env' => env('APP_ENV', 'production'), - 'betsapi_token' => env('BETSAPI_TOKEN', '36152-aeTRNnZxSPUwGe'), - 'txodds_betaid1' => env('TXODDS_TOKEN_SOCCER', 'ident=betaid1&passwd=Dy59vpRC'), - 'txodds_betaid2' => env('TXODDS_TOKEN_OTHER', 'ident=betaid1&passwd=Dy59vpRC'), + 'betsapi_token' => env('BETSAPI_TOKEN', 'ioioioioioio'), + 'txodds_betaid1' => env('TXODDS_TOKEN_SOCCER', 'ioioioioioio'), + 'txodds_betaid2' => env('TXODDS_TOKEN_OTHER', 'ioioioioioio'), + 'logifuture_token' => env('LOGIFUTURE_TOKEN', 'ioioioioioio'), ]; diff --git a/storage/tools/proxy.php b/storage/proxys/proxy.php similarity index 100% rename from storage/tools/proxy.php rename to storage/proxys/proxy.php diff --git a/storage/tools/proxy_logi_auth.php b/storage/proxys/proxy_logi_auth.php similarity index 98% rename from storage/tools/proxy_logi_auth.php rename to storage/proxys/proxy_logi_auth.php index d8226677..4c0cc721 100644 --- a/storage/tools/proxy_logi_auth.php +++ b/storage/proxys/proxy_logi_auth.php @@ -1,7 +1,7 @@