mapper wip
This commit is contained in:
1 parent
ba6c2263e3
commit
02712ec610
27 files changed
+1070
-158
No files matched your search
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Mapper;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class IdMapper
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$test = Nuh::$options['t'] ?? 0;
|
||||
$echo = Nuh::$options['e'] ?? 0;
|
||||
|
||||
$total = 10;
|
||||
|
||||
$bookmakers = [[
|
||||
'name' => 'betfair',
|
||||
'url' => 'https://api.b365api.com/v1/betfair/sb/upcoming?sport_id=###sport_id###&page=###page###',
|
||||
], [
|
||||
'name' => '1xbet',
|
||||
'url' => 'https://api.b365api.com/v1/1xbet/upcoming?sport_id=###sport_id###&page=###page###',
|
||||
]];
|
||||
|
||||
foreach ($bookmakers as $bookmaker) {
|
||||
|
||||
if ($bookmaker['name'] == '1xbet') {
|
||||
// same like txodds
|
||||
$sportmap = [1, 2, 3];
|
||||
} elseif ($bookmaker['name'] == 'betfair') {
|
||||
// 1 soccer
|
||||
// 7522 basketball
|
||||
$sportmap = [1, 7522];
|
||||
}
|
||||
|
||||
foreach ($sportmap as $sport_id) {
|
||||
|
||||
$page = 1;
|
||||
|
||||
$url = str_replace('###sport_id###', $sport_id, $bookmaker['url']).'&token='.config('env.betsapi_token');
|
||||
|
||||
while ($page <= $total) {
|
||||
|
||||
$url = str_replace('###page###', $page, $url);
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
$page++;
|
||||
|
||||
$total = round($data['pager']['total'] / $data['pager']['per_page']);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Page: $page \nTotal: $total");
|
||||
}
|
||||
|
||||
if (isset($data['results'])) {
|
||||
|
||||
foreach ($data['results'] as $row) {
|
||||
if ($bookmaker['name'] == '1xbet') {
|
||||
Mapper::where('betsapi_id', (int) $row['our_event_id'])->update(['_1xbet_id' => (int) $row['id']]);
|
||||
} elseif ($bookmaker['name'] == 'betfair') {
|
||||
Mapper::where('betsapi_id', (int) $row['our_event_id'])->update(['betfairsb_id' => (int) $row['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user