昨日まで、私は iGoogle で動作する完全に機能する予算オーガナイザー サイト/アプリを持っていました。
PHP を介して、次の小さな行を使用して
file_get_contents('http://www.google.com/ig/calculator?hl=en&q=1usd=?eur');
同様に、必要なものはすべて手に入れることができました。
今日の時点で、これは機能しなくなりました。問題を調べたところ、Google が iGoogle を廃止したということです。残念!
とにかく、私は他の場所を探していましたが、自分のニーズに合ったものを見つけることができません. この1行のコードを切り替えるだけで(つまり、Googleアドレスを利用可能な他の通貨APIのアドレスに変更するだけで)修正して再び実行できるようになりたいと思っていますが、そうではないようです。
rate-exchange.appspot.com の API は、iGoogle のアナログのように見えますが、残念ながら、まったく機能しません。「オーバー クォータ」メッセージが表示され続けます。
(最初の質問です。シンプルで信頼性の高い iGoogle ソート API を知っている人はいますか?)
したがって、自然なことは Yahoo YQL 機能になると思います (少なくとも、信頼性は高いと思います)。
Yahoo のクエリは次のようになります。
http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("USDEUR", "USDJPY", "USDBGN")&env=store://datatables.org/alltableswithkeys
私が本当に理解できないのは、このデータを解析する方法です。XML を出力します。
私が以前持っていたのはこれです:
function exchange($inputAmount,$inputCurrency,$outputCurrency) {
$exchange = file_get_contents('http://www.google.com/ig/calculator?hl=en&q='.$inputAmount.$inputCurrency.'=?'.$outputCurrency);
$exchange = explode('"', $exchange);
$exchange = explode('.', $exchange['3']);
$exchange[0] = str_replace(" ", "",preg_replace('/\D/', '', $exchange[0]));
if(isset($exchange[1])){
$exchange[1] = str_replace(" ", "",preg_replace('/\D/', '', $exchange[1]));
$exchange = $exchange[0].".".$exchange[1];
} else{
$exchange = $exchange[0];
}
return $exchange;
}
そのため、ユーザーは、特定の金額について、「USD」などの入力通貨と「EUR」などの出力通貨から為替レートを取得できました。私が言ったように、これは昨日の夜まで問題なく動作していました。
何か案は?