首頁  >  問答  >  主體

PHP file_get_contents 採集為空請指教 ? ?

在調試一個PHP get 請大家


[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 ]



#直接開啟http://kj.kai861.com/view/pk10.html?1?10001?none? 正常


謝謝


#
环城环城2280 天前2059

全部回覆(3)我來回復

  • 小さな手は

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

    API應該是這條:http://api.api68.com/pks/getLotteryPksInfo.do?lotCode=10001

    回覆
    0
  • 环城

    請教這個地址怎麼樣取得的到的?這個是 JSON 格式,可以用

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

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

    我不知道你要取得什麼但是file_get_contents( $api );回傳的是HTML不是JSON所以這個再json_decode一定是錯的

    回覆
    0
  • 环城

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

    JS 產生的動態資料有簡易的取得方法嗎

    回覆
    0
  • 取消回覆