title: file_get_contents failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in
body: <p>I've been provided RESTful URLs to load onto a wordpress site I'm currently updating.  These pages already have RESTful URLs, I'm just updating them with newer URLs. However, once I switch the old with the new I get the following error:</p>
  
  <blockquote>
    <p>Warning:
    file_get_contents(<a href="http://rest.vivapvd.com/agenda/52/2015" rel="nofollow">http://rest.vivapvd.com/agenda/52/2015</a>‐11‐02/)
    [function.file-get-contents]: failed to open stream: HTTP request
    failed! HTTP/1.1 400 Bad Request in
    /nas/...../includes/thomas_functions.php
    on line 86</p>
  </blockquote>
  
  <p>Here is line 86</p>
  
  <pre><code>function fetch_url_content($url=false){
      if(empty($url)) return $url;
      $contents   = file_get_contents($url);
      $array      = json_decode($contents,true);
      return $array;
  }
  </code></pre>
  
  <p><br></p>
  
  <blockquote>
    <p>NOTE: This is suppose to work with a template page, which was prepared by the previous developer.  Here's the page below:</p>
  </blockquote>
  
  <pre><code>&lt;?php
  /*
      Template Name: Agenda Pages
  */
  add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' );
  remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
  add_action( 'genesis_after_content', 'td_custom_page_sidebar' );
  /*---------------------------------------------------------------------------------------*/
  add_action('genesis_after_loop', 'agenda_restful_content');
  function agenda_restful_content(){
      global $post;
      $url = get_post_meta($post-&gt;ID, 'wpcf-rest-url', true);
      $agenda = fetch_url_content($url);
      if($agenda){
          //echo '&lt;pre&gt;'; var_dump($agenda); echo '&lt;/pre&gt;';
          $topictitle=false;
          if(isset($agenda[0]['TopicTitle']) &amp;&amp; !empty($agenda[0]['TopicTitle']))
              echo '&lt;h2&gt;'.$agenda[0]['TopicTitle'].'&lt;/h2&gt;';
          echo '&lt;table&gt;';
              echo '&lt;tbody&gt;';
          foreach($agenda as $a){
              if($topictitle===false)
                  $topictitle=$a['TopicTitle'];
  
              if( $topictitle!=$a['TopicTitle'] ){
                  $topictitle=$a['TopicTitle'];               
                  echo '&lt;/tbody&gt;&lt;/table&gt;';
                  echo !empty($a['TopicTitle']) ? "&lt;h2&gt;$a[TopicTitle]&lt;/h2&gt;" : '';
                  echo '&lt;table&gt;';
                      echo '&lt;tbody&gt;';
              }
          ?&gt;
              &lt;tr&gt;
                  &lt;th class="time"&gt;&lt;?php echo date('g:i A', strtotime($a['StartDate'])) ?&gt;-&lt;?php echo date('g:i A', strtotime($a['EndDate'])) ?&gt;&lt;/th&gt;
                  &lt;td&gt;
                      &lt;?php echo isset($a['Title'])           ? $a['Title'].'&lt;br&gt;'    : ''; ?&gt; 
                      &lt;?php echo isset($a['SpeakerNames'])    ? $a['SpeakerNames']    : ''; ?&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;?php 
          }
          echo '&lt;/tbody&gt;&lt;/table&gt;';
      }
  }
  /*---------------------------------------------------------------------------------------*/
  genesis();
  ?&gt;
  </code></pre>