title: Echo Restful API in php page
body: <p>I need desperate help getting the current tv program broadcasted by a specific channel. I want to use this API <a href="http://www.webtelevideo.com/api/" rel="nofollow">http://www.webtelevideo.com/api/</a> to get the program name. I found this page that grabs all the programs of all the italian TV channels but I want only the currently broadcasted program by a specified channel to show. So without country data, language, rating etc... only the name of the TV program that is on at the moment of viewing the web page. I tried to go to <a href="http://www.webtelevideo.com/api/getSchedule.php?channel_id=350" rel="nofollow">http://www.webtelevideo.com/api/getSchedule.php?channel_id=350</a>  (for example) but I want to make only the CURRENT program to appear, ONLY one string. I know that on the web and here at stackoverflow there are a lot of post about APIs and cURL but I'm a noob in this kind of stuff and I really need your help. Thanks a lot in advance</p>
  
  <pre><code>&lt;?php $guide = get_post_meta($post-&gt;ID, '_wpb_in_onda', true); ?&gt;
  
  &lt;?php
  function GetChanels()
  {
      return json_decode(file_get_contents("http://www.webtelevideo.com/api/getSchedule.php"),true);
  }
  function GetProgramsOnChanel($ChanName)
  {
      foreach(GetChanels() as $Chanel)
      {
          {
              return $Chanel["Program"];
          }
      }
      return Array("name"=&gt;"none");
  }
  function GetCurrentProgramOnChanel($ChanName)
  {
      foreach(GetProgramsOnChanel($ChanName) as $Program)
      {
          $Title = $Program["title"];
          $start = strtotime($Program["ProgramSchedule"]["start"]);
          $end = strtotime($Program["ProgramSchedule"]["stop"]);
          $Current = ($start &lt; strtotime("now +1 hour") and strtotime("now +1 hour") &lt; $end); 
          if($Current)
          {
              return $Program;
          }
      }
      return Array("title"=&gt;"none");
  }
  
  foreach(GetChanels() as $Chan)
  $CurrentProgram = GetCurrentProgramOnChanel(" . $guide . ");
  echo "Ora è in onda: " . $CurrentProgram["title"] . ". ";
  echo "Termina alle: " . $CurrentProgram["ProgramSchedule"]["stop"] . " (ora italiana) &lt;br&gt;";
  ?&gt;
  </code></pre>