1

I Want To make an HTTP Request but I am using HTTPS. whenever I hit the API directly in URL, I am getting the response as shown in below

{"result": 
[[
    "id",
    "number",
    "name",
    "operator_service_name",
    "origin_id",
    "destination_id",
    "route_id",
    "travel_id",
    "bus_type",
    "dep_time",
    "arr_time",
    "duration",
    "available_seats",
    "total_seats",
    "service_tax_percent",
    "fare_str",
    "is_cancellable",
    "commission",
    "status",
    "op_schedule_id",
    "convenience_charge_percent",
    "amenities",
    "boarding_stages",
    "dropoff_stages",
    "deals",
    "cancellation_policies",
    "trip_id",
    "agent_cancellation_time",
    "updated_at",
    "route_map_id",
    "is_service_tax_applicable",
    "via",
    "is_ac_bus",
    "allow_reschedule",
    "travel_date",
    "route_version",
    "bp_dp_fares",
    "bp_dp_pair_fares",
    "city_seq_order",
    "cc_type",
    "main_dep_time",
    "transaction_charges",
    "no_coach_layout"
  ],[
    326404,
    "ban to hyd0001",
    "Bangalore to hyderabad",
    "Siri Travels R5",
    134,
    506,
    34,
    21,
    "2+1, Volvo Semi Sleeper, AC, Non-Video",
    "20:00",
    "10:00",
    "14:00",
    20,
    20,
    0.0,
    "SS:600.0",
    true,
    "",
    "Unavailable-Service Left",
    17859,
    0.0,
    "[\"Reading Light\",\"Snacks\",\"Towel\",\"Water Bottle\",\"WiFi\"]",
    "10934|20:00",
    "9392|10:00",

but when i use the API in the PHP code

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Get the response and close the channel.
$response = curl_exec($ch);
echo $response;
curl_close($ch);

i am getting the response as

x��Y[sۺ~ϯ�詝J .��M������3���L��@$-!�I���Q�{A����2�=C-�.���B�{�H�MZ������o��D��k*��.��i�����:)x��2)�"J��B,E6o��IY��W"��E���]|��c�)��n��b��J�zxQt��P:��-)_� ��We�'�x�e�]T��s�Y�d���̯+�r�,JR%�p���V�����x�)[{��h�ě��q�g�$ ��G+^,�C�`�LT"i-r^�"[��e�E�ί�� O��Y�:�u���[bm-�dռ3�6�f�*����-����l���t�F� n���|���i~7p�V;���սM ����<^���]֚��ˏD����k�q��(�`����J)���k�f�<�y���|���k_;����(��*G�]�1&f��gK��ER���-xcة(�R�(ѥ[� �e��ӄaPRO�!}�1O�9�&�M�$���謏.�l�Q�In�P<��4H�� ����-6˜=�z`Ul���șe���*h�\T?p�C����..]M�rU}������nJE^�wI��F 4Ϋ*M4C�U|�}m�2g��e�B��l��<��j2R2dN��(`2�:dxH�]�գ�M�j�����m,+iyt��B#g`�����= 4��f��`���`O�����ԇ:��Y��?�=.�6�������i��:�z�SK�#����]�k���7��m%���������XS/�* �O~"T��j��=F�^��O<��)�ӧ�^Y����}5�N$͞k�>k ���C׹��F{*���Q��-M<�>�6�h�ߧ�|�Q�T�h���W���O�`XQ�@qT�~*Ué#�J���~*�2�h8nx��TO�L ��֩��VT�����)L�j�öē���Z�>�=�0]祶��'[�KM s��.$x��ҟ��Q�.kGeֆ���wO�N�ѤC��N�t\^�tl�|�Cڸx���m�V��$�1�Y즄�`J(�ll��& ��黎�F�/Y,�"��Mޟ70g�e5|��b�G9jjr�d|�l���l�V�U����:U�¾w_��d�}:`�����)6=<>݃k�t@�����S���OW�x�ؓ�?�$��<�jO�H/�s��g��\y�R���o�g�ij«{h��k�Q�L� QK�8fn-ub~��O�x�����g�J�bI��F15�� $����BǑ��]��hǐ���w���m~����Ѽu޽�v���n7A�D�� :'��-(��̐��G ��խ*i)�$�I��N�:Z�Oʔ?��LF���7a'�o�=p�����-[-7t�W��<��u Є,vEPC0C851��,jf�f�g����Y�� �.�5a�S�}�YNMP�j�C�vj��d��u����Q� jԳZ�#A�3�5��\�m�+^|e�����CW6/��!��nA��"`?/L������>�-��W������i����q�<�*�?����"�C�wgp~v���lW�]9>)��ǎ�!���GHhJ�{�p_�rv�<�C9���P&C'�$�d�$�d�r�q�n��8T�yj��8� ��,��Ϩ$��=`d9·���D  o�.��N��"]��a(I z�S��a}C��P{;{ ��ƺ~���]9B�D�t߹�{�=���;S8�ӻ3����~'Os��x�٥�HU��װ�דg_�:�e�9����4:�(��Q��e���q���k0�n���}�/�{m;M�M!�Znx^�tv�l����Pˈ�\�j78yQ �x1h��@K�vuگ���Z�>�����2���?�7��8j@�L��(����|U�}�ł� �����g1_o �hI�X�y��.�+����������Q�0T��o��%�VQ�[�M��C�e�(�����k�[��^*3����d|�S��@���=�Z����]'��W�2�� ^�x����6��I�Q���2� ]�<.�Q��;^I��^����}Q;n_~%�e�o��_n���QF��X���y��Ld��M��Ѧ'T��'������t�4$;n�&6$?�>�ء�c\�j ��;�Pd��b��Ȼ�w�+Ә:�� ��`��.@�/e����L�����J,�����K��%�,�q��)I���m��ս���[��"ͣ�m?�ϬEt�Y�^����֍�������A}� �>�CXg�t�f��+��}�|��7?���1

as I was thinking that, maybe I did something wrong. But whenever I use different methods, even for that I am getting the same response. please help me...

jaya kumar
  • 11
  • 1
  • `whenever I hit the API directly in URL` - with http, or https? `when i use the API in the PHP code` - with http, or https? These are the only 2 important details, and you didn't mention either of them. – Don't Panic Feb 03 '20 at 09:01
  • with HTTP like http://myurl, I can get the data directly in the browser – jaya kumar Feb 03 '20 at 09:10
  • This looks like you might be dealing with some sort of compressed response, gzipped or deflated. Check if https://stackoverflow.com/questions/3002612/uncompress-a-gzip-file-from-curl-on-php helps. – 04FS Feb 03 '20 at 09:13

0 Answers0