2

I'm using rotten tomatoes API and when I try to get movie information sometimes it returns me normal json as it suppose to, but there are movies in which case it returns something like this

���������[o7���+|�Y��,��nhҠMQ�!p�#--.� ��U����������A�����̙�߽��׃�J\M���(���:W�k���F���

And so on...

I use php to do request, tried to do it with file_get_contents and CURL, result is the same. What it can be?

MrLore
  • 3,759
  • 2
  • 28
  • 36
  • Without any code snippet and a specific case that we can try to reproduce your result, it can be anything really. – mysticalnetcore Feb 11 '14 at 14:42
  • no code is there almost. As i said i use file_get_contents and then printing it – user2851844 Feb 11 '14 at 14:44
  • What is the encoding of your webpage? – Needpoule Feb 11 '14 at 15:04
  • Do you use json_decode on the data you receive from the API? There is a exemple here: http://developer.rottentomatoes.com/docs/read/json/v10/examples What happen if you try this exemple? – Needpoule Feb 11 '14 at 15:20
  • MrShibby, when I'm using json_decode it returns nothing. When I do it returns crap. Yes, i did try that example – user2851844 Feb 11 '14 at 15:24
  • Can you show the response header you get when calling the api? – Needpoule Feb 11 '14 at 15:36
  • { "Cache-Control": "must-revalidate", "Content-Encoding": "gzip", "Content-Language": "en-US", "Content-Type": "text/javascript;charset=ISO-8859-1", "Date": "Tue, 11 Feb 2014 12:52:11 GMT", "Expires": "-1", "Server": "Mashery Proxy", "Vary": "User-Agent,Accept-Encoding", "X-Mashery-Responder": "prod-j-worker-us-east-1d-35.mashery.com", "Content-Length": "1029", "Connection": "keep-alive" } – user2851844 Feb 11 '14 at 16:10

1 Answers1

1

Some of your responses are in gzip format.That's why you have special characters.

You can probably use the "gzdecode" function when you encounter that kind of response:

http://www.php.net/manual/en/function.gzdecode.php

See here : http://developer.rottentomatoes.com/forum/read/156340/2

There are apparently some solutions that may help you.

Needpoule
  • 4,476
  • 24
  • 33