PHP调用汇率源代码
2014-03-26 11:18
239 查看
function getExchangeRate($from_Currency,$to_Curr http:// ency)
{
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "download.finance.yahoo.com/d/quotes.html?s=".$from_Currency.$to_Currency."=X&f=sl1d1t1ba&e=.html";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode(',', $rawdata);
return $data[1];
}
//调用方法
echo getExchangeRate("CNY","USD");
原文转载:http://blog.csdn.net/dongsg11200/article/details/10476411
{
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "download.finance.yahoo.com/d/quotes.html?s=".$from_Currency.$to_Currency."=X&f=sl1d1t1ba&e=.html";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode(',', $rawdata);
return $data[1];
}
//调用方法
echo getExchangeRate("CNY","USD");
原文转载:http://blog.csdn.net/dongsg11200/article/details/10476411
相关文章推荐
- PHP调用java的class
- HippCRM入口 index.php源代码解析
- 用PHP调用数据库的存贮过程
- php 调用python 脚本
- PHP_PDO 调用mysql 带返回参数的存储过程
- 在WinCE下调用校准触摸屏的API和源代码
- php调用远程url的四种方法
- 在smarty中调用php的内置函数
- PHP调用webservice的用法
- PHP怎样调用MSSQL的存储过程
- paip.java c# .net php python调用c++ c dll so windows api 总结
- php调用酷狗音乐APi
- 关于IIS php调用com组件的权限问题
- PHP调用控制台EXE程序的方法
- php微信高级接口调用方法(自定义菜单接口、客服接口、二维码)
- kindEditor完整认识 PHP上调用并上传图片说明
- 用动态网页技术PHP生成验证码图片的源代码
- 用PHP调用.net写的WebService服务端
- php 怎么确保两个函数被调用的顺序
- php链式调用