Created
November 9, 2015 13:43
-
-
Save guyoun/d0e7da5b3ca90f97725b to your computer and use it in GitHub Desktop.
KTH H3 등록
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$http_header = array(); | |
/** | |
* Get the header info to store. | |
*/ | |
function getHeader($ch, $header) { | |
global $http_header; | |
$i = strpos($header, ':'); | |
if (!empty($i)) { | |
$key = str_replace('-', '_', strtolower(substr($header, 0, $i))); | |
$value = trim(substr($header, $i + 2)); | |
$http_header[$key] = $value; | |
} | |
return strlen($header); | |
} | |
$url = "http://h3.kthcorp.com/2012/h3api/postReg"; | |
$method = 'POST'; | |
$postfields = array('email'=>'[email protected]','name'=>'xxxx', 'company' =>'xxxx'); | |
$http_info = array(); | |
$ci = curl_init(); | |
/* Curl settings */ | |
curl_setopt($ci, CURLOPT_USERAGENT, "H3"); | |
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); | |
curl_setopt($ci, CURLOPT_TIMEOUT, 30); | |
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:')); | |
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ci, CURLOPT_HEADERFUNCTION, 'getHeader'); | |
curl_setopt($ci, CURLOPT_HEADER, FALSE); | |
switch ($method) { | |
case 'POST': | |
curl_setopt($ci, CURLOPT_POST, TRUE); | |
if (!empty($postfields)) { | |
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); | |
} | |
break; | |
} | |
curl_setopt($ci, CURLOPT_URL, $url); | |
$response = curl_exec($ci); | |
$http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE); | |
$http_info = array_merge($http_info, curl_getinfo($ci)); | |
if (curl_errno($ci)) { | |
print curl_error($ci); | |
} | |
curl_close ($ci); | |
echo "http:" . $http_code . "<br/>"; | |
print_r( $http_info); | |
print_r( $http_header); | |
echo "response:" . $response . "<br/>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment