@@ -278,7 +278,7 @@ public function getLineData2($path, $get)
278278 return false ;
279279
280280 $ url = 'http://www.szjt.gov.cn/BusQu/APTSLine.aspx/GetData2 ' ;
281- $ param = '{"guid":" ' . $ get ['LineGuid ' ]. '"} ' ;
281+ $ param = '{"guid":" ' .$ get ['LineGuid ' ].'"} ' ;
282282 $ header = [
283283 'content-type: Application/json ' ,
284284 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 ' ,
@@ -292,7 +292,25 @@ public function getLineData2($path, $get)
292292 $ res = json_decode ($ data ['content ' ], true );
293293 if (isset ($ res ['d ' ])) {
294294 $ arr = json_decode ($ res ['d ' ], true );
295- return $ arr ['Document ' ] ?? [];
295+ // 处理数组
296+ $ return = [];
297+ if ($ arr ['Document ' ]) {
298+ $ lName = $ arr ['Document ' ]['LName ' ] ?? '' ;
299+ $ lDir = $ arr ['Document ' ]['LDirection ' ] ?? '' ;
300+ $ return ['to ' ] = $ lName .'- ' .$ lDir ;
301+
302+ foreach ($ arr ['Document ' ]['StandInfo ' ] as $ item ) {
303+ $ return ['line ' ][] = [
304+ 'stationName ' => $ item ['SName ' ] ?? '' ,
305+ 'stationCode ' => $ item ['SCode ' ] ?? '' ,
306+ 'carCode ' => $ item ['BusInfo ' ] ?? '' ,
307+ 'ArrivalTime ' => str_replace ('/ ' , '- ' , $ item ['InTime ' ] ?? '' ),
308+ 'OutTime ' => str_replace ('/ ' , '- ' , $ item ['OutTime ' ] ?? '' ),
309+ 'SGuid ' => $ item ['SGuid ' ] ?? '' ,
310+ ];
311+ }
312+ return $ return ;
313+ }
296314 }
297315 }
298316 return [];
0 commit comments