grapper betsapi
This commit is contained in:
1 parent
406fd26864
commit
a3c9f16550
127 files changed
+158128
-650
No files matched your search
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Bet365
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
/**
|
||||
* Bet365
|
||||
*/
|
||||
$bookmaker_id = 126;
|
||||
|
||||
$res = Event::where('bet365_id', '>', 0)->pluck('id', 'bet365_id');
|
||||
|
||||
foreach ($res as $bet365_id => $txodds_id) {
|
||||
|
||||
/**
|
||||
* BET365 ODDS (per event)
|
||||
*/
|
||||
$url = 'https://api.b365api.com/v4/bet365/prematch?token='.config('env.betsapi_token').'&FI='.$bet365_id;
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
dd($data);
|
||||
|
||||
$betsapi_id = $data['results'][0]['id'] ?? 0;
|
||||
$bet365_id = $data['results'][0]['bet365_id'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(["TXdds ID : $txodds_id", "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", "Willhill ID : $willhill_id"], 'b');
|
||||
}
|
||||
|
||||
if ($betsapi_id) {
|
||||
Event::where('id', (int) $txodds_id)->update(['betsapi_id' => $betsapi_id, 'bet365_id' => $bet365_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Betfair
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
/**
|
||||
* Bet365
|
||||
*/
|
||||
$bookmaker_id = 126;
|
||||
|
||||
$res = Event::where('bet365_id', '>', 0)->pluck('id', 'bet365_id');
|
||||
|
||||
foreach ($res as $bet365_id => $txodds_id) {
|
||||
|
||||
/**
|
||||
* BETFAIR SP (per page)
|
||||
* https://api.b365api.com/v1/bwin/prematch?token=36152-aeTRNnZxSPUwGe
|
||||
*/
|
||||
$url = 'https://api.b365api.com/v4/bet365/prematch?token='.config('env.betsapi_token').'&FI='.$bet365_id;
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
dd($data);
|
||||
|
||||
$betsapi_id = $data['results'][0]['id'] ?? 0;
|
||||
$bet365_id = $data['results'][0]['bet365_id'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(["TXdds ID : $txodds_id", "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", "Willhill ID : $willhill_id"], 'b');
|
||||
}
|
||||
|
||||
if ($betsapi_id) {
|
||||
Event::where('id', (int) $txodds_id)->update(['betsapi_id' => $betsapi_id, 'bet365_id' => $bet365_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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');
|
||||
|
||||
$total = 1;
|
||||
foreach ($sportmap as $sport_id => $bwin_sport_id) {
|
||||
|
||||
$page = 1;
|
||||
|
||||
/**
|
||||
* BWIN ODDS & BETRADAR ID (per page)
|
||||
*/
|
||||
$url = 'https://api.b365api.com/v1/bwin/prematch?token='.config('env.betsapi_token').'&page=###page###&sport_id='.$bwin_sport_id;
|
||||
|
||||
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 $event) {
|
||||
|
||||
$bwin_id = $event['Id'];
|
||||
$betradar_id = $event['BetRadarId'] ?? 0;
|
||||
$betsapi_id = $event['our_event_id'];
|
||||
|
||||
if ($betradar_id) {
|
||||
Event::where('betsapi_id', (int) $betsapi_id)->update(['betradar_id' => $betradar_id, 'bwin_id' => $bwin_id]);
|
||||
|
||||
Mapper::where('event_id', $betsapi_id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,10 @@ class Fixtures
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$test = Nuh::$options['t'] ?? 0;
|
||||
$echo = Nuh::$options['e'] ?? 0;
|
||||
|
||||
$sportmap = Sport::map('bapi');
|
||||
|
||||
$total = 10;
|
||||
$total = 1;
|
||||
foreach ($sportmap as $sport_id => $betsapi_sport_id) {
|
||||
$page = 1;
|
||||
while ($page <= $total) {
|
||||
@@ -41,7 +39,7 @@ class Fixtures
|
||||
foreach ($data['results'] as $row) {
|
||||
|
||||
$event = [
|
||||
'sport_id' => (int) $row['sport_id'],
|
||||
'sport_id' => (int) $sport_id,
|
||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
|
||||
'home' => $row['home']['name'] ?? '',
|
||||
@@ -55,7 +53,7 @@ class Fixtures
|
||||
'group_cc' => $row['league']['cc'] ?? '',
|
||||
];
|
||||
|
||||
Mapper::updateOrCreate(['betsapi_id' => (int) $row['id']], $event);
|
||||
Mapper::updateOrCreate(['event_id' => (int) $row['id']], $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
<?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']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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\Odds3way;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Willhill
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
/**
|
||||
* williamhill
|
||||
*/
|
||||
$bookmaker_id = 42;
|
||||
|
||||
$res = Odds3way::join('events', 'odds_3ways.event_id', 'events.id')
|
||||
->where('odds_3ways.bookmaker_id', $bookmaker_id)
|
||||
->where('events.betsapi_id', 0)
|
||||
->where('odds_3ways.bmoid', '>', 0)->pluck('odds_3ways.event_id', 'odds_3ways.bmoid');
|
||||
|
||||
foreach ($res as $willhill_id => $txodds_id) {
|
||||
|
||||
$url = 'https://api.b365api.com/v1/williamhill/result?token='.config('env.betsapi_token').'&event_id='.$willhill_id;
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
$betsapi_id = $data['results'][0]['id'] ?? 0;
|
||||
|
||||
$bet365_id = $data['results'][0]['bet365_id'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(["TXdds ID : $txodds_id", "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", "Willhill ID : $willhill_id"], 'b');
|
||||
}
|
||||
|
||||
if ($betsapi_id) {
|
||||
Event::where('id', (int) $txodds_id)->update(['betsapi_id' => $betsapi_id, 'bet365_id' => $bet365_id]);
|
||||
|
||||
Mapper::where('event_id', $betsapi_id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user