Retrieve contents from a JSON URL using cURL and display them in an HTML table I am trying to display contents retrieved from an external URL using JSON (the cURL method). So i wrote the below function:

function file_get_contents_curl() {
  //JSON URL which should be requested
  $gry_str = "?timezone=" . urlencode(date_default_timezone_get())  . "&amp;dateFrom=" . date('Y-m-d') . "&amp;dateTill=" . date('Y-m-d');

  $json_url = 'https://www.example.com/json/financial-calendar.json' . $gry_str;

  // Initializing curl
  $ch = curl_init(); 

  //Configuring curl options 
  $options=array(CURLOPT_RETURNTRANSFER =&gt; true, 
    CURLOPT_HTTPHEADER =&gt; array('Content-type: application/json'),
    CURLOPT_URL =&gt; $json_url);

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

  //Getting resutls
  $results= curl_exec($ch); //Getting json result string
}


I want the contents retrieved to be displayed in an HTML table. So i am using this:

&lt;script id="calendarContentTemplate" type="text/html"&gt;
&lt;![CDATA[
  &lt;tr&gt;
    &lt;td class="calendar-local-time"&gt;&lt;%= time %&gt;&lt;/td&gt;
    &lt;td class="region"&gt;&lt;%= region %&gt;&lt;/td&gt;
    &lt;td class="title"&gt;&lt;%= title %&gt;&lt;/td&gt;
    &lt;td&gt;&lt;%= forecast %&gt;&lt;/td&gt;
    &lt;td&gt;&lt;%= previous %&gt;&lt;/td&gt;
  &lt;/tr&gt;
]]&gt;


and my constructed table like this:

&lt;table class="calendar-table"&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th class="time"&gt;Time&lt;/th&gt;
      &lt;th class="region"&gt;Region&lt;/th&gt;
      &lt;th class="title"&gt;Event&lt;/th&gt;
      &lt;th class="forecast"&gt;Forecast&lt;/th&gt;
      &lt;th class="previous"&gt;Previous&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;   
    &lt;tr&gt;    
      &lt;td class="calendar-local-time"&gt;&lt;/td&gt;    
      &lt;td class="region"&gt;&lt;/td&gt;    
      &lt;td class="title"&gt;&lt;/td&gt;      
      &lt;td&gt;&lt;/td&gt;    
    &lt;/tr&gt;   
  &lt;/tbody&gt;
&lt;/table&gt;


Nothing is being displayed on the table. Am I doing something wrong? Or do I need a Drupal function to make it work? Forgot to mention that its for the front page. 

I have read about the drupal_json_output() function. But I am not sure if I have to use it. When I tried using it my webpage appeared only HTML. 

It is very weird, because when I open Firebug I can see in the Net section. I am receiving Status as 200 Ok for request, but the response is completely empty. 

Any help is greatly appreciated.
Have you tried drupal_json_decode? drupal_json_decode give you back a object that you can use for  print the variables.

https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_json_decode/7