The received json file cannot be parsed. you must use php to parse function & nbsp; sendPost ($ url, $ postData) {& nbsp; $ postdata & nbsp ;=& nbsp; http_build_query ($ postData); & nbsp; $ options & nbsp ;=& nbsp; The json received by a cannot be parsed and must be parsed using php.
Function sendPost ($ url, $ postData ){
$ Postdata = http_build_query ($ postData );
$ Options = array (
'Http' => array (
'Method' => 'post ',
'Header' => 'Content-type: application/x-www-form-urlencoded ',
'Content' => $ postdata,
'Timeout' => 15*60 // timeout (unit: s)
)
);
$ Context = stream_context_create ($ options );
$ Result = file_get_contents ($ url, false, $ context );
Return $ result;
}
$ Url = "http://chepiao.sinaapp.com/api.php? Act = remain ";
$ Data = array (
"Date" = & gt; "20131220 ",
"StartStation" => "Beijing ",
"ArriveStation" => "Tianjin"
);
$ Result = sendPost ($ url, $ data );
$ Obj = json_decode ($ result );
$ Result is the returned data, that is, the data cannot be parsed, and json_decode ($ result) is used; the parsed result is NULL.
Share: More