Search code examples
phpencodingrotten-tomatoes

API request returns crap in some cases


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?


Solution

  • 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.