title: Using file_get_contents to get og:image meta data throws "failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden" with some websites
body: <p>I'm trying to use php to get meta data like og:image, title or description.</p>
  
  <p>I'm using that code:</p>
  
  <pre><code>&lt;?php
  $sites_html = file_get_contents($url);
  
  $html = new DOMDocument();
  @$html-&gt;loadHTML($sites_html);
  $meta_og_img = null;
  //Get all meta tags and loop through them.
  foreach($html-&gt;getElementsByTagName('meta') as $meta) {
      //If the property attribute of the meta tag is og:image
      if($meta-&gt;getAttribute('property')=='og:image'){
          //Assign the value from content attribute to $meta_og_img
          $meta_og_img = $meta-&gt;getAttribute('content');
      }
  }
  echo $meta_og_img;
  ?&gt;
  </code></pre>
  
  <p>When I use this url (<a href="https://www.elmundo.es/papel/2019/01/28/5c4ed8effc6c83d2718b4605.html" rel="nofollow noreferrer">https://www.elmundo.es/papel/2019/01/28/5c4ed8effc6c83d2718b4605.html</a>) it works perfectly but when I use this one (<a href="https://andresmartin.org/2016/09/mindfulness-la-fibromialgia-mirar-dolor-amabilidad-alivia-malestar-reduce-dolor/" rel="nofollow noreferrer">https://andresmartin.org/2016/09/mindfulness-la-fibromialgia-mirar-dolor-amabilidad-alivia-malestar-reduce-dolor/</a>), I get the error.</p>
  
  <p>How can I avoid this error? And if it is impossible to do, how can I get the meta data with another method?</p>
  
  <p>I think it is not important but I'm using laravel.</p>
  
  <p>EDIT: Here is a screenshot of the error <a href="https://pasteboard.co/HYPI7KV.png" rel="nofollow noreferrer">https://pasteboard.co/HYPI7KV.png</a></p>