PHP file_get_contents 採集為空請指教 ? ?
环城
环城 2018-06-24 09:47:20
0
3
2057

在調試一個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? 正常


謝謝


#
环城
环城

全部回覆(3)
小さな手は

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

  • 回覆 請教這個地址怎麼樣取得的到的?這個是 JSON 格式,可以用
    环城 作者 2018-06-24 16:10:49
小さな手は

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

环城

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

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!