Json connection returning null and error-free in the json_errors variable

Asked

Viewed 64 times

2

Code being used in a php in the /root folder:

<?php

$jsoncontent = file_get_contents('https://xx.xxx.xx.xxx/v1/API_operation');
$jsoncontent = utf8_encode($jsoncontent);
$data = json_decode($jsoncontent,true);
echo $data;

$json_errors = array(
    JSON_ERROR_NONE => 'No error has occurred',
    JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
    JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
    JSON_ERROR_SYNTAX => 'Syntax error',
);
 echo 'Last error : ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL;

The result is Last error : No error has occurred, but it does not display any component/object of the referent link, what can I do?

When I do var_dump($http_response_header); receiving:

array(9) { 
    [0]=> string(22) "HTTP/1.1 404 Not Found" 
    [1]=> string(25) "Server: Apache-Coyote/1.1" 
    [2]=> string(103) "X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)/JBossWeb-2.0" 
    [3]=> string(35) "Date: Sat, 23 May 2015 05:24:02 GMT" 
    [4]=> string(20) "Accept-Ranges: bytes" 
    [5]=> string(31) "Server: Restlet-Framework/2.0.7" 
    [6]=> string(37) "Content-Type: text/html;charset=UTF-8" 
    [7]=> string(19) "Content-Length: 439" 
    [8]=> string(17) "Connection: close"
}
  • What gives you echo utf8_encode($jsoncontent);?

  • nothing..... continue only appearing to last error msg

  • Okay, and what gives var_dump($http_response_header); shortly after $jsoncontent = file_get_contents('https://xx.xxx.xx.xxx/v1/API_operation');?

  • 1

    result is: array(9) { [0]=> string(22) "HTTP/1.1 404 Not Found" [1]=> string(25) "Server: Apache-Coyote/1.1" [2]=> string(103) "X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)/JBossWeb-2.0" [3]=> string(35) "Date: Sat, 23 May 2015 05:24:02 GMT" [4]=> string(20) "Accept-Ranges: bytes" [5]=> string(31) "Server: Restlet-Framework/2.0.7" [6]=> string(37) "Content-Type: text/html;charset=UTF-8" [7]=> string(19) "Content-Length: 439" [8]=> string(17) "Connection: close" } Last error : No error has occurred

  • @Maybe the problem is using the protocol Https, you have enabled extension=php_openssl.dll in your file php.ini?

  • In the first element of this array has HTTP/1.1 404 Not Found. Have you tried that url to see if it exists?

  • @Sergio my new totally reworked code is here http://answall.com/questions/66531/request-object-json-sempre-returned-null-em-php, could verify what the probable cause of it still results null, however in one of the attempts demonstrated there he accessed the server, but without return of the variables... thank you

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.