title: Downloading an image that is hotlink protected
body: <p>I would like to download an image that is hotlink protected. How can I forge the HTTP header with CURL to say the referer is coming from its own server?</p>
  
  <p>I have tried with this command but it fails. I'm not familiar with PHP and help would be much apreciated.</p>
  
  <pre><code>curl -A "Mozilla/5.0" -L -b /tmp/c -c /tmp/c -s 'http://remote-site.com/image.jpg' &gt; image.jpg
  </code></pre>
  
  <p>Option looks to be <code>CURLOPT_REFERER</code> with <code>curl_setopt</code>, or <code>curl --referer</code> but not sure about the correct syntax.</p>
  
  <hr>
  
  <p>EDIT 2 :</p>
  
  <p>I got an error saying that curl_setopt() expects parameter 2 to be long. After removing the MUTE option the error is gone.</p>
  
  <p>To show the image I have tried this code but the page remains blank.</p>
  
  <pre><code>$image = curl_exec($ch);
  curl_close($ch);
  fclose($fp);
  print '&lt;img src="'.$image.'"/&gt;';
  </code></pre>
  
  <hr>
  
  <p>EDIT 1: </p>
  
  <p>The code I have entered in my Wordpress post (I use the plugin <a href="http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php" rel="nofollow">Insert PHP</a>) </p>
  
  <pre><code>[insert_php]
  
  curl --referer http://www.DOMAIN.com/ -A "Mozilla/5.0" -L -b /tmp -c /tmp -s 'http://www.DOMAIN.com/image.png' &gt; image.png
  
  [/insert_php]
  </code></pre>
  
  <p>The error I have when I load the page :</p>
  
  <pre><code>Parse error: syntax error, unexpected ‘&lt;‘ in /public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 8
  </code></pre>