Created
March 28, 2013 07:01
-
-
Save nikuuchi/5261247 to your computer and use it in GitHub Desktop.
file_get_contentsでPOSTする
This file contains hidden or 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 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