search

Home  >  Q&A  >  body text

PHP file_get_contents collection is empty. Please give me some advice? ?

While debugging a PHP get, please


##[code=php]<?php

$api = 'http://kj. kai861.com/view/pk10.html?1?10001?none?';

$resource = file_get_contents( $api );

$data = json_decode( $resource , 1 );

$ct = $data['c_t'];

$cd = $data['c_d'];

$cr = $data['c_r'] ;

header('Content-Type: text/xml;charset=utf8');

$limit=strlen($ct)-3;

$ct= substr($ct,0,$limit).''.substr($ct,$limit,$limit 3);


## function tmp($v){

return 10>$v?"0{$v}":$v;

}

$cr=implode(',',array_map('tmp', array_slice(explode(',',$cr),0,20)));

echo '<xml>

<row expect="'.$ct.'" opencode="'.$cr.'" opentime="'.str_replace('/','-',$cd).'"/>

</xml>';[/code ]



Directly open http://kj.kai861.com/view/pk10.html?1?10001?none? Normal


Thanks

环城环城2438 days ago2219

reply all(3)I'll reply

  • 小さな手は

    小さな手は2018-06-24 15:30:29

    The API should be this: http://api.api68.com/pks/getLotteryPksInfo.do?lotCode=10001

    reply
    0
  • 环城

    How did you get this address? This is in JSON format and can be used

    环城 · 2018-06-24 16:10:49
  • 小さな手は

    小さな手は2018-06-24 15:28:02

    I don’t know what you want to get, but file_get_contents( $api ); returns HTML, not JSON, so this json_decode must be wrong.

    reply
    0
  • 环城

    环城2018-06-24 11:08:07

    Is there an easy way to obtain dynamic data generated by JS?

    reply
    0
  • Cancelreply