dtype == "line" and $events[$i]["game_start"] > ($time_nom + 8600)) { continue; } $timestamp = $events[$i]["game_start"]; $ready_html .= " " . (round($events[$i]["timer"] / 60)) . " минута - ". $date = date('d/m - H:i', $timestamp) ."
" . $events[$i]["game_id"] . " - " . $events[$i]["sport_name"] . " - " . $events[$i]["tournament_name"]. " - " . $events[$i]["opp_1_name"] . " - " . $events[$i]["opp_2_name"] . " " . $events[$i]["game_dop_name"] . " "; $ready_html .= ''; $event = $events[$i]; $list_html = ""; for ($j = 0; $j < count($event["game_oc_list"]); $j++) { $temp_oc = $event["game_oc_list"][$j]; $list_html .= " "; } $list_html = '
" . $temp_oc["oc_name"] . " - " . $temp_oc["oc_rate"] . "
' . $list_html . '

'; $ready_html .= $list_html; } return '' . $ready_html . '
'; } public function events_get() { $url = $this->api_host . "/v1/events/1/0/list/100/" . $this->dtype . "/ru"; // /v1/events/1, where the number 1 is the sport of soccer. Play any other sport $data_raw = get_request($url); $data = json_decode($data_raw, true); if ($data["status"] == 1) { return $this->events_render($data["body"]); } return ""; } /////////////////////////////////////////////// Full view for sports matches EVENT ///////////////////////////////////////////// public function event_render($event) { $ready_html = "
Back

" . $event["game_id"] . " - " . $event["sport_name"] . " - " . $event["opp_1_name"] . " - " . $event["opp_2_name"] . " " . $event["game_dop_name"]. "- { ---" .$event["period_name"]. "
"; $gamescore_html = "
" .$event["score_full"]. "(" .$event["score_period"]. ")
"; $list_html = ""; ///////////////////// SUB GAMESS ////////////// for ($k = 0; $k < count($event["sub_games"]); $k++) { $temp_sub_oc = $event["sub_games"][$k]; $list_html .= " ". $temp_sub_oc["game_id"] ." - " . $temp_sub_oc["game_name"] ."
"; } for ($i = 0; $i < count($event["game_oc_list"]); $i++) { $temp_oc = $event["game_oc_list"][$i]; $list_html .= " " . $temp_oc["oc_name"] . " - " . $temp_oc["oc_rate"] . " - (" . $temp_oc["oc_pointer"] . ") "; } $list_html = '' . $list_html . '
'; return $ready_html . $gamescore_html . $list_html; } ///////////////////// Code ONLY for sending bets to our system - if you use only sports api - you can delete this section of the code////////////// public function event_get($game_id = null) { // $url = $this->api_host . "/v1/event/" . $game_id . "/list/" . $this->dtype . "/ru"; $data_raw = get_request($url); $data = json_decode($data_raw, true); if ($data["status"] == 1) { return $this->event_render($data["body"]); } return ""; } public function send($dtype, $bet_pointer) { $dataSend = array( "data" => array( "list_bets" => array($dtype . '#' . $bet_pointer . '#1'), "realAmount" => "150", "currency" => "RUB", "lang" => "ru", "remote_host" => "https://mysite.loc", ) ); $host_prod = 'https://{Calc_url}'; $request = post_request($host_prod . '/bet/place/', json_encode($dataSend)); return $request; } } $api_obj = new API(); $ready_html = ""; if (isset($_GET['game_id']) or !empty($_GET['game_id'])) { $ready_html = $api_obj->event_get($_GET['game_id']); } if (isset($_GET['bet_pointer']) or !empty($_GET['bet_pointer'])) { $ready_html = $api_obj->send($api_obj->dtype, $_GET['bet_pointer']); $answer = json_decode($ready_html, true); if ($answer["errorMessage"] == "Неверный уровень доступа") { $dataSend = array( "login" => 'user_mail', // need to get from technical support "password" => "user_password" // need to get from technical support ); $host_prod = 'https://{Calc_url}'; // need to get from technical support $ready_html = post_request($host_prod . '/WebServices/BCService.asmx/LogIn/', json_encode($dataSend)); $ready_html .= $api_obj->send($api_obj->dtype, $_GET['bet_pointer']); sleep(5); if (isset($_SERVER["HTTP_REFERER"])) { header("Location: " . $_SERVER["HTTP_REFERER"]); } } } else if (!isset($_GET['game_id']) or empty($_GET['game_id'])) { $ready_html = $api_obj->events_get(); } ?> API