티스토리 뷰

아마도 전력데이터 서버가 우리 웹서버로부터의 접속을 허용하지 않는 것으로 판단됨.

 

<Source code>

	public function CollectEPowerData($Conn){
		global $ServiceKey;
		// http://bilientsvc.net/Tests/OpenAPITest11.php?RequestType=collectEPowerData
		$ch = curl_init(); // curl session
		$url = 'https://openapi.kpx.or.kr/openapi/sukub5mMaxDatetime/getSukub5mMaxDatetime'; /*URL*/
		//$queryParams = '?'.urlencode('serviceKey')."=".urlencode($ServiceKey);/*Service Key*/
		$queryParams = '?serviceKey='.$ServiceKey;/*Service Key*/
		echo "[Request]".$url.$queryParams."<br>";
        $agent = 'Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0';

		curl_setopt($ch, CURLOPT_URL, $url.$queryParams);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
		curl_setopt($ch, CURLOPT_HEADER, FALSE);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
		curl_setopt($ch, CURLOPT_USERAGENT, $agent);
		curl_setopt($ch, CURLOPT_TIMEOUT, 5);
		$response = curl_exec($ch);
		curl_close($ch);
		echo "[Response]";
		var_dump($response);
	}

<Result>

반응형

'SWDesk > Web' 카테고리의 다른 글

JSON 배열 전송 및 수신 : PHP to Python  (2) 2021.01.15
[PHP] Dict Key Value  (0) 2020.10.20
PHP, XML, Encoder, Example  (0) 2020.10.02
(X)Python Code for Collecting Weather Data  (0) 2020.10.01
기상정보 수집을 위한 웹 소스(1)  (0) 2020.10.01