New OTC real-time stock information interface calling code example based on PHP
Aggregated data New Third Board real-time stock information interface: https://www.juhe.cn/docs/api/id/185. If necessary, you need to apply for APPKEY through this.
Example: // +-------------------------------------------------- -----------------------
// | JuhePHP [NO ZUO NO DIE]
// +-------------------------------------------------- -----------------------
// | Copyright (c) 2010-2015 http://juhe.cn All rights reserved.
// +-------------------------------------------------- -----------------------
// | Author: Juhedata
// +-------------------------------------------------- -----------------------
//----------------------------------
// New OTC real-time stock information calling sample code - aggregated data
// Online interface documentation: http://www.juhe.cn/docs/185
//----------------------------------
header('Content-type:text/html;charset=utf-8');
//Configure the appkey you applied for
$appkey = "**********************";
//************1.Real-time stock information************
$url = "http://touchstone.api.juhe.cn/ajax/data/realtime";
$params = array(
"key" => $appkey,//APPKEY you applied for
"pageIndex" => "",//Number of pages, such as: 1
"id" => "",//Security code, such as: 430032, supports fuzzy query
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
If($result['error_code']=='0'){
print_r($result);
}else{
echo $result['error_code'].":".$result['reason'];
}
}else{
echo "Request failed";
}
//************************************************ **
/**
* Request the interface to return the content
* @param string $url [Requested URL address]
* @param string $params [requested parameters]
* @param int $ipost [Whether to use POST form]
* @return string
*/
function juhecurl($url,$params=false,$ispost=0){
$httpInfo = array();
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
If($ispost)
{
curl_setopt( $ch , CURLOPT_POST , true );
curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
curl_setopt( $ch , CURLOPT_URL , $url );
}
else
{
if($params){
curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
}else{
curl_setopt( $ch , CURLOPT_URL , $url);
}
}
$response = curl_exec( $ch );
if ($response === FALSE) {
//echo "cURL Error: " . curl_error($ch);
return false;
}
$httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
$httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
curl_close( $ch );
return $response;
}
The difference between large function and max
What is the encoding used inside a computer to process data and instructions?
The difference between anchoring and aiming
A complete list of commonly used public dns
what does element mean
How to delete my WeChat address
Bitcoin historical price chart
How to center div in css