title: JSON API request in PHP not working Properly
body: <p>I'm struggling to retrieve data from an API using PHP.</p>
  <p>My PHP code:</p>
  <pre><code>&lt;?php
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, &quot;https://api.coronavirus.data.gov.uk/v1/data?filters=areaName=United%2520Kingdom;areaType=overview&amp;structure={%22areaName%22:%22areaName%22,%22date%22:%22date%22,%22newCasesByPublishDate%22:%22newCasesByPublishDate%22,%22cumCasesByPublishDate%22:%22cumCasesByPublishDate%22}&quot;);
  
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($curl);
  curl_close($curl);
  
  echo $output;
  ?&gt;
  </code></pre>
  <p>Sadly this just outputs a random list of characters like this:</p>
  <pre><code>��9|_��M�\�E�JЀ���&quot;�H*p�Kx���,:VK�`&gt;���m��a˒��܆�V^��gt�d�e]���������������f�ӷ�7�?_�\=�^Z)�b�j��߽�����������{����������tu�������7����+/J���~���������&gt;������o&gt;|�y�v�����s��Et{���i��L;�+&gt;�Pq�F7��ĵQ�u�q9s��e��*͈f hkh�T����Ӵn�ճ�4�Dk�4��E��q��J����XUi�4-r��j�9UZB���s)�J9��a&amp;�z�� �$�Ͳ��n &amp;��4����� �a* ��UP�:Gz�4В:�Z�Pc�@KZsښJU'���mĔ3�@Kj�4KSU�@Kꜧ7�ڇ��ZR����ZUyݨ2I����`�֭�ӴQ�u-Y{JZX�i�%5*dwZ�;����4�Ű�FI�%A��3�������E�u��{@�e@TZm�uWidsVm� j�˱�`�V$��hrz�\���4�������Fǜ��%˩e�xQ��J-F�*�к�m��.��Q��y�m��2�4�+ݚJ��Ts�R�(!Ge�t���\��F�e���)� �kȤ�ZN4Tf��-���ςhَ&amp;*���T�ɕ����ZA �R.&quot;��0�Y�#��Ԓ-��ֿ0�l#?թL�Uj��l,$�+md��t0�ȒLv�VM����f�$Abm�L#%)�hU�d�Sf�ݬ�vL�FǼ�k�VE�ܔ�%Y�/z�n��c�=UE&amp;35��yd $3`�ʲ&gt;jf��֬t�E��TvY��׬��(@&quot;]�9%�u��4�'E���U�utQcК�}�T��*�浨0�J%T�Z� ��AkVr�kFj����iL ��0�+S��Y�H9�&gt;u���S�O�S�I0��|�95-���g���Q +1d(HHԮ�Y�M=���IM�i8���T�PA��Ta�Ԇ��O���$*%�2����o�aU&lt;��h��RR�2�.�@��cf�aT�8��JkF �!�O#y&amp;����h$˔ #׎���yς�&amp;è� ��|DO�;Z��$X3U��2yX�b��e��0��Ȩ�4���ZT&lt;�iCK�D�t�i��D���m���Pa� k!����D3&amp;^��������e֔i�2:��s�4�j��*��]z�3�G�tT�g&lt;.�&amp;7����V����^yY٦N$9�%���TF�a?ÿ�T׍��Q���e��6�w2�~L��m� �C�E��@wԏV^�7l5�uk�DPixZ\˅Ny��6�'���&quot;�d�ͭ�5lj��}�J��88��Z�J���S�Ir5V��g�M��#[cx�5�}M�:��k{Suo� \7˔i�%��[�=BUe�U�p���%U��V]@[my�Z��.�V�*���z�4����݇�]�R^&amp;�V�� o� �ɜ&amp;^stS^(&amp;���ʁv�W�p}l�\T)��]�@;�f *��S�U�YD�������\%��ft��*�(���ZO�z���@G�͐6L9*O�W�-[Qu�S������L��n��݊��B�sJ���M�Q����&gt;�+ �F�)9�|��f7?�D�ó�%��Ҁ�������al6m�c#GUǄ(�pyl䨖Z��cVS�q�O�t�PV��1I�j��%Ŭ��F���(�*�)�7�h%�*�U��\����VA�ڠ�~Fл��{k����Rh�b{���i�nv��M� |Ƙhf-TZ����{���&amp;6�z��uW��UC��&amp;�7kC�����D�n��T3�i�.�'��6��w1���,M��B{7e�r@M��81��м�Tc���]TiDR�G�Y K5���`���d��9�G�%����=�r(Й �W���Zx���q�@�^�P���b Oi�S1� &amp;���sB@��sF#G�oB�M(e U�_�26��M(� %6��M(�99�Y�?T�mB)爲J�']N3*��W���7��93&amp;S��}W)mJ݄�P��O1l=����U]�&gt;]_� �[��V��(��V���n�@�h+e�����R�Jl+e�����R�Jl+e�����R���2����l�e+e([)C�J��������7W��ǫ����w������_��}u�������������ot�����������������˻����W��?&lt;�?}��t�|ֿ~����_��_/��}����_��&gt;~۩ώ?����S�=��&lt;}w��������5-��_��_fk��������ç�����m��3W��ߦ���x����⶷nx 
  </code></pre>
  <p>Putting the url directly into a browser works fine, giving a nice JSON, see <a href="https://api.coronavirus.data.gov.uk/v1/data?filters=areaName=United%2520Kingdom;areaType=overview&amp;structure=%7B%22areaName%22:%22areaName%22,%22date%22:%22date%22,%22newCasesByPublishDate%22:%22newCasesByPublishDate%22,%22cumCasesByPublishDate%22:%22cumCasesByPublishDate%22%7D" rel="nofollow noreferrer">see here</a>.</p>
  <p>I'm really scratching my head to know where to go from here to get this to parse properly in PHP.</p>
  <p>Can anyone help, I'm completely out of my depth here.</p>