From 2b6bf969afdd6ee80369e6543901073c44eea113 Mon Sep 17 00:00:00 2001 From: wonipapa Date: Mon, 19 Jun 2017 16:22:54 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BB=A4=EB=84=A5=EC=85=98=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EA=B4=80=EB=A0=A8=EC=98=88=EC=99=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epg2xml-web.php | 61 ++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/epg2xml-web.php b/epg2xml-web.php index dce3f38..6c072b9 100644 --- a/epg2xml-web.php +++ b/epg2xml-web.php @@ -1,7 +1,7 @@ $day ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "POST"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -506,9 +506,9 @@ function GetEPGFromKT($ChannelInfo) { 'tab_no' => '1' ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "GET"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -581,9 +581,9 @@ function GetEPGFromLG($ChannelInfo) { 'evntCmpYmd' => $day ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "POST"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -662,9 +662,9 @@ function GetEPGFromSK($ChannelInfo) { 'pcode' => '|^|start_time='.$today.'00|^|end_time='.$lastday.'24|^|svc_id='.$ServiceId ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "POST"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -741,9 +741,9 @@ function GetEPGFromSKY($ChannelInfo) { 'indate_type' => 'now' ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "POST"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -827,9 +827,9 @@ function GetEPGFromNaver($ChannelInfo) { 'where' => 'nexearch' ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "GET"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -920,9 +920,9 @@ function GetEPGFromMbc($ChannelInfo) { 'rtype' => 'json' ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "GET"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -994,9 +994,9 @@ function GetEPGFromMil($ChannelInfo) { 'program_date' => date("Ymd", strtotime($day)) ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "GET"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -1069,9 +1069,9 @@ function GetEPGFromIfm($ChannelInfo) { 'viewDt' => $day ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "GET"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -1138,9 +1138,9 @@ function GetEPGFromKbs($ChannelInfo) { 'channel'=>'wink_11' ); $params = http_build_query($params); - $url = $url."?".$params; + $method = "GET"; try { - $response = getWeb($url); + $response = getWeb($url, $params, $method); if ($response === False && $GLOBALS['debug']) : printError($ChannelName.HTTP_ERROR); else : @@ -1294,13 +1294,22 @@ function writeProgram($programdata) { endif; fprintf($fp, " \n"); } -function getWeb($url) { +function getWeb($url, $params, $method) { $ch = curl_init(); + if($method == "GET"): + $url = $url."?".$params; + elseif($method == "POST"): + curl_setopt ($ch, CURLOPT_POST, True); + curl_setopt ($ch, CURLOPT_POSTFIELDS, $params); + endif; curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['ua']); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,True); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); + curl_setopt($ch, CURLOPT_HEADER, False); + curl_setopt($ch, CURLOPT_FAILONERROR,True); + curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['ua']); $response = curl_exec($ch); + if(curl_error($ch) && $GLOBALS['debug']) printError($url." ".curl_error($ch)); curl_close($ch); return $response; }