php curl操作
1111111111111111111111111111111
$url = "http://stock.liangyee.com/bus-api/stock/freeStockMarketData/GetMarketData?userKey=??????&symbol=600000,600300&type=0 ";
$a=file_get_contents($url);
$b=json_decode($res, true);
222222222222222222222222222222222222222222
/* 注册用户 */ function funcHttpRegUser($args) { global $configs; $ary = array( 'token' => $args['token'], 'userId' => $args['userId'], 'loginName' => $args['loginName'], 'loginPwd' => $args['loginPwd'], 'userMobile' => $args['userMobile'] ); //$ary['signNo'] = md5(formatBizQueryParaMap($ary, true)); //print_r($ary); $res = doCurl($configs['http']['url']['reguser'], formatBizQueryParaMap($ary, false)); return json_decode($res, true); } //执行CURL function doCurl($url, $data = null) { global $configs; if (empty($url)) return false; $curl = curl_init(); //设置超时 curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_URL, $url); if (!empty($data)) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $res = curl_exec($curl); curl_close($curl); return (!$res) ? false : $res; }
javascript curl操作
var test='{ colkey: "hq_str_sh", colsinfo: "601006" }' var obj2=eval("("+test+")"); var url="http://hq.sinajs.cn/list=sh"+obj2.colsinfo; //alert(url); $.ajax({ url:"http://hq.sinajs.cn/list=sh601006", dataType:"script", cache:"false", type:"GET", success:function(a){ //alert(eval(obj2.colkey+obj2.colsinfo)); } })