Lottery Result API Creation – Fetch with Curl and Create Interface JSON and XML Format
Lottery API interface production – curl to get and produce interface JSON and XML format
//header(‘Content-Type:text/json;charset=utf8’);
header(‘Content-type:text/xml’);
$api = ‘https://api.api.com/pks/getLotteryPksInfo.do?lotCode=10037’;
$resource = file_get_contents_by_curl($api);
$data = json_decode($resource, 1);
//$rq= 20 . $data[‘result’][‘data’][‘preDrawIssue’];
$rq = $data[‘result’][‘data’][‘preDrawIssue’];
$hm = $data[‘result’][‘data’][‘preDrawCode’];
$sj = $data[‘result’][‘data’][‘preDrawTime’];
//echo ‘{ sign :true, message : Successfully obtained , data :[{ title : Fast Racing , name : pl3 , expect : ‘.$rq.’ , opencode : ‘.$hm.’ , opentime : ‘.str_replace(‘/’,’-‘,$sj).’ , source : Lottery Collection , sourcecode : }]}’;
echo ‘‘;
echo ‘
echo ‘‘;
function file_get_contents_by_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
?>
Time getting API
header(‘Content-Type:text/json;charset=utf8’);
//header(‘Content-type:text/xml’);
$api = ‘http://api.k780.com:88/?app=life.time&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json’;
$resource = file_get_contents_by_curl($api);
$data = json_decode($resource, 1);
//$rq= 20 . $data[‘result’][‘data’][‘preDrawIssue’];
$time1 = $data[‘result’][‘datetime_1’];
$time2 = $data[‘result’][‘timestamp’];
//$time3=$data[‘result’][‘datetime_2’];
//$sj=$data[‘result’][‘data’][‘preDrawTime’];
echo ‘{ “sysTime2” : ‘ . $time1 . ‘ , “sysTime1” : ‘ . $time2 . ‘ }’;
/*echo ‘‘;
echo ‘
echo ‘‘;*/
function file_get_contents_by_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
?>
-
Alipay QR Code Scan
-
WeChat Scan Pay