Google货币转换器API-是否可以通过iGoogle关闭? [英] Google currency converter API - will it shut down with iGoogle?

查看:126
本文介绍了Google货币转换器API-是否可以通过iGoogle关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iGoogle 关闭

有一个(未记录?)货币转换API,可通过以下网址获得:
http://www.google.com/ig/calculator?hl=zh-CN&q=1GBP=?USD

There is an (undocumented?) currency conversion API available with URLs like: http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD

此基础url-google.com/ig-带您前往iGoogle。在iGoogle关闭后,该API是否可用?

The base of this url - google.com/ig - takes you to iGoogle. Will the API be available after iGoogle shuts down?

推荐答案

我遇到了以下相同的问题: https://stackoverflow.com/a/19786423/2819754

I was having the same issue described here: https://stackoverflow.com/a/19786423/2819754

我用过@hobailey直到我可以将其更新到另一个版本或Google决定做一个适当的api为止。

I used @hobailey answer for a temporary fix until i can update it to another version or google decide to do a proper api.

随着Google将URL更改为

As google changed the URL to

  https://www.google.com/finance/converter?a

所以我找到的解决方法如下。

So the fix i found is below.

  $amount = urlencode($amount);
  $from_Currency = urlencode($from_Currency);
  $to_Currency = urlencode($to_Currency);
  $get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
  $get = explode("<span class=bld>",$get);
  $get = explode("</span>",$get[1]);  
  $converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);

感谢@hobailey提供此小技巧。

thanks to @hobailey for this little fix.

这篇关于Google货币转换器API-是否可以通过iGoogle关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆