天天看點

競彩足球混合過關賠率API調用示例代碼

<?php

// +----------------------------------------------------------------------

// | 競彩足球混合過關賠率API調用示例代碼 - 麥趣資料

// | 線上接口文檔:

http://www.Matchodds.info // | Copyright (c) 2018 http://Matchodds.info

// | Author: 麥趣資料 < QQ:2578620058 -->

// | Info: 本接口為api示範

header('Content-type:text/html;charset=utf-8');

$host="http://120.79.248.89/apidemo/football/";

$method = "GET"; //GET/POST

//$querys = "mid=110188"; //指定單場賽事

$appkey="ApiD08D636E54F031E63FeBF8D1a2N9e"; //AppKey

$url = $host . "?" . $querys."&appkey=".$appkey;

//curl驗證

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_FAILONERROR, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(

//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

'Content-Type: application/json',           

));

$result = curl_exec($ch);

if (curl_errno($ch)) {

print curl_error($ch);           

}

curl_close($ch);

//echo $result;

$obj=json_decode($result, true);

if($obj['code']=='200'){ echo "請求成功

";

foreach ( $obj['data'] as $arr ){

$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']; //比賽更新資訊
if(strlen($mid)>0){
echo "賽事ID:".$mid."<br>";
echo "場次:".$num."<br>";
echo "比賽時間:".$dtime."<br>";
echo "聯賽名稱:<font color=$l_color>".$l_cn."</font><br>";
echo "主隊名稱:".$h_cn."<br>";
echo "客隊名稱:".$a_cn."<br>";
echo "賽事狀态:".$status."<br>";
echo "盤口狀态:".$p_status."<br>";
echo "單關1是0否:".$p_single."<br>";
echo "讓球數:".$p_goal."<br>";
echo "勝平負賠率:".$had_odds."<br>";
echo "讓球勝平負:".$hhad_odds."<br>";
echo "比分勝賠率:".$crs_win."<br>";
echo "比分平賠率:".$crs_draw."<br>";
echo "比分負賠率:".$crs_lose."<br>";
echo "總進球賠率:".$ttg_odds."<br>";
echo "半全場賠率:".$hafu_odds."<br>";
echo "聯賽簡稱:".$l_cn_a."<br>";
echo "主隊簡稱:".$h_cn_a."<br>";
echo "客隊簡稱:".$a_cn_a."<br>";
echo "主隊排名:".$h_order."<br>";
echo "客隊排名:".$a_order."<br>";
echo "色标:".$l_color."<br>";
echo "天氣:".$weather."<br>";
}           

}else{ echo "請求失敗 $result"; };

?>