Skip to content

Instantly share code, notes, and snippets.

@nikuuchi
Created March 28, 2013 07:01
Show Gist options
  • Select an option

  • Save nikuuchi/5261247 to your computer and use it in GitHub Desktop.

Select an option

Save nikuuchi/5261247 to your computer and use it in GitHub Desktop.
file_get_contentsでPOSTする
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('send_post'))
{
function send_post($data,$url)
{
$header = array(
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: ".strlen($data)
);
$context = array(
"http" => array(
"method" => "POST",
"header" => implode("\r\n", $header),
"content" => $data
)
);
return file_get_contents($url, false, stream_context_create($context));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment