我想将XE货币转换器集成到我的网站,但希望在我的网站上输出相同的网页,而不是重定向到XE网站,如何实现这一点?与iframe?请你能提供一个例子吗?非常感谢。cakephp和XE货币转换器?
0
A
回答
0
你可以从他们的网页数据的饲料,它看起来像: http://www.xe.com/datafeed/
这样,您可以通过PHP /卷曲等检索货币和与它只是正常的数据。
2
你其实可以提交查询xe.com和使用curl
<?php
$url = "http://www.xe.com/currencyconverter/convert/?Amount=1&From=USD&To=PHP";
$ch = curl_init(); // Initialize a CURL session.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Return Page contents.
curl_setopt($ch, CURLOPT_URL, $url); // Pass URL as parameter.
$data = curl_exec($ch); // grab URL and pass it to the variable.
curl_close($ch); // close curl resource, and free up system resources.
$dom = new DOMDocument();
@$dom->loadHTML($data);
$xpath = new DOMXPath($dom);
$tableRows = $xpath->query('//table//tr');
$details = array();
foreach ($tableRows as $row) {
// fetch all 'tds' inside this 'tr'
$td = $xpath->query('td', $row);
if ($td->length == 3 ):
foreach($td as $key => $val){
if($key==0 Or $key ==2) {
$details[] = preg_replace('/[^a-zA-Z0-9, \'\.:]*/i', '',$val->nodeValue);
}
}
endif;
}
print "<pre>";
print_r($details);
print "</pre>";
?>
访问解析来自它的数据:http://myphptroubles.blogspot.com/2013/09/convert-currency-using-xecom-via-curl.html
相关问题
- 1. 货币转换器
- 2. 货币XE计算
- 3. 转换货币
- 4. angularjs货币转换器
- 5. 谷歌货币转换器
- 6. WebServicex货币转换器API
- 7. 货币转换器问题
- 8. Django货币转换
- 9. Javascript货币转换
- 10. 收集从geoplugin货币转换器返回的货币 - PHP
- 11. 使用angularjs的货币转换器
- 12. 货币转换器! (如果语句)
- 13. Knockout Circular Reference(简单货币转换器)
- 14. 如何包含货币转换器?
- 15. 在Swift中创建货币转换器
- 16. 货币转换器Web服务
- 17. 货币转换器在HTML + PHP
- 18. Angular2管转换货币
- 19. Rails中的货币转换
- 20. 转换条纹货币
- 21. Magento完成货币转换
- 22. 货币转换程序
- 23. 转换货币价值
- 24. 转换为货币格式
- 25. 转换小数货币和背部
- 26. cakephp格式货币区域
- 27. 在前面转换货币的货币,angularJS
- 28. 将货币/货币转换为Cent,反之亦然
- 29. 转换成ISO 4217的数字货币代码货币名称
- 30. Android:试图转换时货币转换器崩溃
我仍然在规划一个新手,你有什么例子?这将非常感激。谢谢。 – Nick 2013-04-08 10:15:28
嗯,饲料成本540美元,忘记那部分:-) – Nick 2013-04-08 10:27:31
我只是使用这个:https://github.com/dereuromark/tools/blob/master/Lib/CurrencyLib.php – mark 2013-04-08 10:46:03