本文整理匯總了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');
}