本文整理汇总了PHP中zmf::curlget方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::curlget方法的具体用法?PHP zmf::curlget怎么用?PHP zmf::curlget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::curlget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionExrates
/**
* 获取汇率
* 雅虎YQL https://developer.yahoo.com/yql/console/
* 请求语句 select * from yahoo.finance.xchange where pair="CNYUSD,CNYHKD"
* 示例 https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22CNYUSD%2CCNYHKD%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=
*/
public function actionExrates()
{
$units = tools::getUnits();
unset($units['CNY']);
$arr = array();
foreach ($units as $k => $v) {
$arr[] = 'CNY' . $k;
}
$str = join(',', $arr);
$url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22{$str}%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=";
$output = zmf::curlget($url);
if (!$output) {
exit('Failed');
}
$rateArr = CJSON::decode($output);
$rateArr = $rateArr['query']['results']['rate'];
foreach ($rateArr as $val) {
$_key = str_replace('CNY', '', $val['id']);
$rates[$_key] = array('rate' => $val['Rate'], 'title' => tools::getUnits($_key));
}
$detailDir = Yii::app()->basePath . '/runtime/rates/';
zmf::createUploadDir($detailDir);
$dir = $detailDir . 'detail.log';
file_put_contents($dir, CJSON::encode($rates));
exit('well done');
}