Skip to content

Instantly share code, notes, and snippets.

@guyoun
Created November 9, 2015 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyoun/d0e7da5b3ca90f97725b to your computer and use it in GitHub Desktop.
Save guyoun/d0e7da5b3ca90f97725b to your computer and use it in GitHub Desktop.
KTH H3 등록
<?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'=>'xxxx@gmail.com','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