wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Bwin
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$sportmap = Sport::map('bwin');
|
||||
|
||||
foreach ($sportmap as $bwin_sport_id) {
|
||||
|
||||
$page = 1;
|
||||
$total = 10;
|
||||
|
||||
/**
|
||||
* BWIN ODDS & BETRADAR ID (per page)
|
||||
* only get BETRADAR ID no storing of data
|
||||
*/
|
||||
$base_url = 'https://api.b365api.com/v1/bwin/prematch?token='.config('env.betsapi_token').'&skip_markets=1&page=###page###&sport_id='.$bwin_sport_id;
|
||||
|
||||
while ($page <= $total) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Page: $page \Sport: $bwin_sport_id", 'b');
|
||||
}
|
||||
|
||||
$url = str_replace('###page###', $page, $base_url);
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
if (isset($data['pager'])) {
|
||||
$total = round($data['pager']['total'] / $data['pager']['per_page']);
|
||||
}
|
||||
|
||||
$page++;
|
||||
|
||||
if (isset($data['results'])) {
|
||||
foreach ($data['results'] as $event) {
|
||||
if ($debug && isset($event['HomeTeam']) && isset($event['SportName'])) {
|
||||
Notice::note($event['RegionName'].'-'.$event['SportName']."\n".$event['HomeTeam'].' - '.$event['AwayTeam']);
|
||||
}
|
||||
|
||||
$betsapi_id = $event['our_event_id'] ?? 0;
|
||||
|
||||
$betradar_id = $event['BetRadarId'] ?? 0;
|
||||
|
||||
$bwin_id = $event['Id'] ?? 0;
|
||||
|
||||
if ($betradar_id && $betsapi_id) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(["Betsapi ID : $betsapi_id", "Betradar ID : $betradar_id", "Bwin ID : $bwin_id"]);
|
||||
}
|
||||
|
||||
Event::where('betsapi_id', (int) $betsapi_id)->update(['betradar_id' => $betradar_id, 'bwin_id' => $bwin_id]);
|
||||
|
||||
Mapper::where('betradar_id', $betradar_id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user