private function _sendRequest($url) { $content = ""; if(function_exists('file_get_contents')) { $content = @file_get_contents($url); } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //allow redirects curl_setopt($ch, CURLOPT_HEADER, false); $content = curl_exec($ch); $error = curl_errno($ch); $info = curl_getinfo($ch); curl_close($ch); } $contenArr = json_decode($content); if(json_last_error() === JSON_ERROR_NONE) { return $contenArr; } else { return $content; }
Directly in the browser knocking back is returned 0001 with this method is 1 so reserved in front of the0
Reply content:
private function _sendRequest($url) { $content = ""; if(function_exists('file_get_contents')) { $content = @file_get_contents($url); } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //allow redirects curl_setopt($ch, CURLOPT_HEADER, false); $content = curl_exec($ch); $error = curl_errno($ch); $info = curl_getinfo($ch); curl_close($ch); } $contenArr = json_decode($content); if(json_last_error() === JSON_ERROR_NONE) { return $contenArr; } else { return $content; }
Directly in the browser knocking back is returned 0001 with this method is 1 so reserved in front of the0
Json_decode did a good job.
$content was 0001, you Json_decode ($content) to convert it to a value of 1.
Are you sure that Curl was executed, and why not file_get_contents?
Json_decode is used to encode a JSON-formatted string, is it a JSON string, please? Is it surrounded by double quotes?