竞彩足球混合过关赔率API调用示例代码2020版

$user = ‘smmz’;
$secret = ‘2e54c7eae2c5a6c01’;
//竞彩足球混合过关数据

// +———————————————————————-
// | 竞彩足球混合过关赔率API调用示例代码 - 麦趣数据
// | 在线接口文档:http://www.Matchodds.info
// +———————————————————————-
// | Copyright (c) 2018 http://Matchodds.info
// +———————————————————————-
// | Author: 麦趣数据
// | Info: 本接口为api演示
// +———————————————————————-
$url = ‘http://open.sportnanoapi.com/api/v2/sports/jc/oddser=’.$user.”&secret=”.$secret;
$obj = Libraries::curl_request($url);
$arr = json_decode($obj, true);

$jczq = $arr[‘data’][‘jczq’];

$color = “”;

foreach ($jczq as $k => $v) {
    $info = array();
    //足球ID
    $info[‘matchId’] = $v[‘id’];
    $info[‘short_comp’] = $v[‘short_comp’];
    $info[‘short_home’] = $v[‘short_home’];
    $info[‘short_away’] = $v[‘short_away’];
    //赛事名称
    $info[‘gameName’] = $v[‘comp’];
    //主队名称
    $info[‘homeName’] = $v[‘home’];
    //客队名称
    $info[‘guestName’] = $v[‘away’];
    $info[‘ball’] =explode(‘,’,$v[‘rq’])[0];
    $orderid = substr($v[‘issue_num’],1);
    $info[‘orderid’] = $orderid;
    //1001
    $info[‘weekid’] = substr($v[‘issue_num’],0,1);
    //截至时间
    $info[‘matchtime’] = date(‘Y-m-d H:i:s’,$v[‘match_time’]);
    $matchtime = date(‘Y-m-d H:i:s’,$v[‘match_time’]);
    if(substr($v[‘issue_num’],0,1)         if(strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 22:00:00″,strtotime(” $matchtime -1 day”))))>0
            &&strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 09:00:00”,strtotime($matchtime))))             $info[‘endtime’] = date(“Y-m-d H:i:s”,strtotime(date(date(“Y-m-d 21:51:00”,strtotime(“$matchtime -1 day”)))));
        }else if(strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 22:00:00”,strtotime($matchtime))))             &&strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 09:00:00”,strtotime($matchtime))))>0){
            $info[‘endtime’] = date(“Y-m-d H:i:s”,strtotime($matchtime) – “540”);
        }else if(strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 22:00:00”,strtotime($matchtime))))>0
            &&strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 09:00:00”,strtotime(“$matchtime +1 day”))))             $info[‘endtime’] = date(“Y-m-d H:i:s”,strtotime(date(date(“Y-m-d 21:51:00”,strtotime($matchtime)))));
        }
    }else{
        //2019-09-08 10:00:00
        if(strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 23:00:00″,strtotime(” $matchtime -1 day”))))>0
            &&strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 09:00:00”,strtotime($matchtime))))             $info[‘endtime’] = date(“Y-m-d H:i:s”,strtotime(date(date(“Y-m-d 22:51:00”,strtotime(“$matchtime -1 day”)))));
        }else if(strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 23:00:00”,strtotime($matchtime))))             &&strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 09:00:00”,strtotime($matchtime))))>0){
            $info[‘endtime’] = date(“Y-m-d H:i:s”,strtotime($matchtime) – “540”);
        }else if(strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 23:00:00”,strtotime($matchtime))))>0
            &&strtotime(date(“Y-m-d H:i:s”,strtotime($matchtime)))- strtotime(date(date(“Y-m-d 09:00:00”,strtotime(“$matchtime +1 day”))))             $info[‘endtime’] = date(“Y-m-d H:i:s”,strtotime(date(date(“Y-m-d 22:51:00”,strtotime($matchtime)))));
        }
    }
    //只要比赛时间没超过11:00
    dump($matchtime);
    dump(date(“Y-m-d 11:00:00”,strtotime(“$matchtime +1 day”)));

    if(strtotime($matchtime)-strtotime(date(“Y-m-d 11:00:00”,strtotime(“$matchtime +1 day”)))         $info[‘lottery_num’] = date(‘Ymd’,strtotime($matchtime));
        if(strtotime($matchtime)-strtotime(date(“Y-m-d 00:00:00”,strtotime(“$matchtime +1 day”)))>=0){
            $info[‘lottery_num’] = date(‘Ymd’,strtotime(“$matchtime -1 day”));
        }
    }
    //销售状态
    //胜平负,让球胜平负,比分,进球,半全场; 0-未开售 1-仅过关 2-单关和过关 3-无
    $info[‘state’] = $v[‘sell_status’];
    //判断是否是单关
    //销售状态5位,顺序为: 胜平负,让球胜平负,比分,进球,半全场; 0-未开售 1-仅过关 2-单关和过关 3-无
    if(explode(‘,’,$v[‘sell_status’])[0] == ‘2’){
        $info[‘isdanguan’] = 1;
    }else{
        $info[‘isdanguan’] = 0;
    }
    if(explode(‘,’,$v[‘sell_status’])[1] == ‘2’){
        $info[‘c_isdanguan’] = 1;
    }else{
        $info[‘c_isdanguan’] = 0;
    }
    //胜负实时赔率
    $info[‘real_odds’] = $v[‘spf’];
    //让球胜平负实时赔率
    if(substr($v[‘rq’],0,1) == ‘-‘){
        $newrq = substr($v[‘rq’], 3, strlen($v[‘rq’]));
    }else{
        $newrq = substr($v[‘rq’], 2, strlen($v[‘rq’]));
    }
    //总进球数实时赔率
    $info[‘real_a_odds’] = $v[‘jq’];
    //半全场实时赔率
    $info[‘real_h_odds’] = $v[‘bqc’];
    $info[‘real_c_odds’] = $newrq;
    $bf = explode(‘,’,explode(‘,’,$v[‘bf’])[12].’,’.$v[‘bf’]);
    foreach ($bf as $k => $v){
        $bf[13] = $bf[18];
    }
    foreach ($bf as $k => $v) {
        $bf[18] = $bf[31];
    }
    $newbf = implode(“,”, $bf);
    $newbf = substr($newbf,0,strrpos($newbf,’,’));
    //比分实时赔率
    $info[‘real_s_odds’] = $newbf;
    if (strtotime($info[‘matchtime’]) – strtotime($addtime) > 0) {
        $wheres = ” orderid ='{$orderid}’  and  lottery_num ='{$info[‘lottery_num’]}’  and  weekid ='{$info[‘weekid’]}’   “;
        $count = $db->pe_num(‘jcteam’, $wheres);
        if (!$count) {
            try {
                $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0);
                $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                $db->beginTransaction();
                dump($info);
                $id = $db->pe_insert(“jcteam”,$info);
                $db->commit();
            } catch (Exception $e) {
                $db->rollBack();
                // throw $e;
                file_put_contents(‘logs/jczq_get_fleaphp.com_error1.log’, $addtime . ‘ ‘ . $e->getMessage() . PHP_EOL, FILE_APPEND);
            }
        } else {
            $matchList = $db->pe_select(‘jcteam’, $wheres, ‘state,matchtime,endtime’);

            if ($matchList[‘state’] == 1 || strtotime($matchList[‘endtime’]) > strtotime($info[‘endtime’])) {
                unset($info[‘endtime’]);
            }
            if ($matchList[‘state’] == 1 || strtotime($matchList[‘matchtime’]) > strtotime($info[‘matchtime’])) {
                unset($info[‘matchtime’]);
            }
            if (!str_replace(“,”, “”, $info[‘real_odds’])) unset($info[‘real_odds’]);
            if (!str_replace(“,”, “”, $info[‘real_c_odds’])) unset($info[‘real_c_odds’]);
            if (!str_replace(“,”, “”, $info[‘real_a_odds’])) unset($info[‘real_a_odds’]);
            if (!str_replace(“,”, “”, $info[‘real_s_odds’])) unset($info[‘real_s_odds’]);
            if (!str_replace(“,”, “”, $info[‘real_h_odds’])) unset($info[‘real_h_odds’]);
            $info_1 = $info;
            unset($info_1[‘orderid’]);
            unset($info_1[‘lottery_num’]);
            unset($info_1[‘weekid’]);
            $id = $db->pe_update(‘jcteam’, $wheres, $info_1);
        }
    }
}

字段说明:

$mid = $arr[‘mid’]; //赛事ID
$num = $arr[‘num’]; //场次(例:1001 = 周一001)
$dtime = $arr[‘dtime’]; //比赛时间
$l_id = $arr[‘l_id’]; //联赛ID    
$l_cn = $arr[‘l_cn’]; //联赛名称    
$h_id = $arr[‘h_id’]; //主队ID    
$h_cn = $arr[‘h_cn’]; //主队名称
$a_id = $arr[‘a_id’]; //客队ID    
$a_cn = $arr[‘a_cn’]; //客队名称    
$status = $arr[‘status’]; //赛事状态1正常0停售
$p_status = $arr[‘p_status’]; //盘口状态1正常0停售顺序(胜平负,让球胜平负,比分,总进球,半全场)
$p_single = $arr[‘p_single’]; //单关1是0否顺序(胜平负,让球胜平负,比分,总进球,半全场)
$p_goal = $arr[‘p_goal’]; 让球数顺序(胜平负,让球胜平负,比分,总进球,半全场)
$had_odds = $arr[‘had_odds’]; //胜,平,负赔率
$hhad_odds = $arr[‘hhad_odds’]; //让球胜,平,负赔率
$crs_win = $arr[‘crs_win’]; //比分胜赔率(1:0,2:0,2:1,3:0,3:1,3:2,4:0,4:1,4:2,5:0,5:1,5:2,胜7+)
$crs_draw = $arr[‘crs_draw’]; //比分平赔率(0:0,1:1,2:2,3:3,平7+)
$crs_lose = $arr[‘crs_lose’]; //比分负赔率(0:1,0:2,1:2,0:3,1:3,2:3,0:4,1:4,2:4,0:5,1:5,2:5,负7+)
$ttg_odds = $arr[‘ttg_odds’]; //总进球赔率(0球,1球,2球,3球,4球,5球,6球,7+球)    
$hafu_odds = $arr[‘hafu_odds’]; //半全场赔率(胜胜,胜平,胜负,平胜,平平,平负,负胜,负平,负负)
$l_cn_a = $arr[‘l_cn_a’]; //联赛简称
$h_cn_a = $arr[‘h_cn_a’]; //主队简称
$a_cn_a = $arr[‘a_cn_a’]; //客队简称
$h_order = $arr[‘h_order’]; //主队排名
$a_order = $arr[‘a_order’]; //客队排名
$l_color = $arr[‘l_color’]; //色标
$weather = $arr[‘weather’]; //天气,城市,温度摄氏度
$match_info = $arr[‘match_info’]; //比赛更新信息

echo “赛事ID:”.$mid.”
“;
echo “场次:”.$num.”
“;
echo “比赛时间:”.$dtime.”
“;
echo “联赛名称:”.$l_cn.”
“;
echo “主队名称:”.$h_cn.”
“;
echo “客队名称:”.$a_cn.”
“;
echo “赛事状态:”.$status.”
“;
echo “盘口状态:”.$p_status.”
“;
echo “单关1是0否:”.$p_single.”
“;
echo “让球数:”.$p_goal.”
“;
echo “胜平负赔率:”.$had_odds.”
“;
echo “让球胜平负:”.$hhad_odds.”
“;
echo “比分胜赔率:”.$crs_win.”
“;
echo “比分平赔率:”.$crs_draw.”
“;
echo “比分负赔率:”.$crs_lose.”
“;
echo “总进球赔率:”.$ttg_odds.”
“;
echo “半全场赔率:”.$hafu_odds.”
“;
echo “联赛简称:”.$l_cn_a.”
“;
echo “主队简称:”.$h_cn_a.”
“;
echo “客队简称:”.$a_cn_a.”
“;
echo “主队排名:”.$h_order.”
“;
echo “客队排名:”.$a_order.”
“;
echo “色标:”.$l_color.”
“;
echo “天气:”.$weather.”
“;

 

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年5月15日
下一篇 2020年5月15日

相关推荐