title: How to Convert Currency using google currency API in Php?
body: <p>I am using google currency conversion API in php by using file_get_content but unable to get output because of getting error ,so how to convert any currency by using following  API in Php.</p>
  
  <pre><code>&lt;?php  
   function convertCurrency($amount, $from, $to)  
   {  
        $url = "http://www.google.com/finance/converter?a=$amount&amp;from=$from&amp;to=$to";  
        $data = file_get_contents($url);  
        preg_match("/&lt;span class=bld&gt;(.*)&lt;\/span&gt;/",$data, $converted);  
        return $converted[1];  
   }  
   echo convertCurrency(1500, 'USD', 'INR');  
   ?&gt; 
  </code></pre>
  
  <p>Getting error like this </p>
  
  <pre><code>Message: file_get_contents(http://www.google.com/finance/converter?a=1500&amp;from=USD&amp;to=INR): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/j2DRY.jpg"/></p>