0

I am currently trying to get a simple HTTP JSON response from a website. When I look at the page when I use Google Chrome:

{"columns":[{"name":"xx","dataType":"varchar","size":255,"nullable":true},{"name":"xx","dataType":"varchar","size":255,"nullable":true},{"name":"xx","dataType":"decimal","size":17,"nullable":true},{"name":"xx","dataType":"varchar","size":255,"nullable":true},{"name":"xx","dataType":"varchar","size":4,"nullable":true},{"name":"xx","dataType":"varchar","size":2,"nullable":true},{"name":"xx","dataType":"varchar","size":20,"nullable":true}],"rows":[["xxxxx","xxxx/xxxx","xxxx","Yacouba","5xx","xx","xxxxx"]]}

However when I use the following php code:

<?php
$json_url = "xxxx"; // url is something else but privacy reasons etc
// Initializing curl
$ch = curl_init();

// Configuring curl options
$options = array(
    CURLOPT_URL => $json_url,
    CURLOPT_POST => FALSE
);

// Setting curl options
curl_setopt_array($ch, $options);

// Getting results
$result = curl_exec($ch); // Getting jSON result string
curl_close($ch);

json_decode($result);

var_dump($result);

and then the output is as fallows:

‹ì½`I–%&/mÊ{JõJ×àt¡€`$Ø@ìÁˆÍæ’ìiG#)«*ÊeVe]f@Ìí¼÷Þ{ï½÷Þ{ï½÷º;N'÷ßÿ?\fdlöÎJÚÉž!€ªÈ?~|?"~ñGÓª\/–ÍG¾÷‹?Zf‹ü£Gͪ¦)òú÷/³I^~4úh–µÙ›ë¾ºÌêé<«éæø}°wÿþè£åº¤¦%ýÙÖëü—Œz€–Y¶ø8—U=ËëbyñûÏòIÑæëú÷¯Vù²i³l9Ïòi±ÈJx÷Á&ü´E°iëŒÞÕyóû¯¦¿ÿ²n6CÛ¿=¬²½ ØÞmFXçeÖ9¡v°´ï>ª«+pÈ÷>ÚýôÓ{Ôúm±l&y}‘/ïþ>Ù´ZO2úpoow´»C¿¹ÏîïìJ?žŸÐ?;;;û÷÷?Ýûèûßÿ%ÿOÿÿzbool(true)

What could the problem be?

4
  • do you have compression on or is the other server returning UTF-8? Commented Feb 4, 2015 at 17:41
  • I am not sure it is running UTF-8, it aint my server :(. can I check it somehow? Commented Feb 4, 2015 at 17:50
  • Did you check the value of $result before applying json_decode? Commented Feb 4, 2015 at 17:53
  • yeah its the same as before json_decode :( Commented Feb 4, 2015 at 18:09

1 Answer 1

1

I fix it! :D with:

CURLOPT_ENCODING => ''
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.