Created
May 31, 2013 18:45
-
-
Save weishai/5687049 to your computer and use it in GitHub Desktop.
curl请求实例
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 | |
$data = array ('context' => '明天去打篮球'); | |
$data = http_build_query($data); | |
$opts = array ( | |
'http' => array ( | |
'method' => 'POST', | |
'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . | |
"Content-Length: " . strlen($data) . "\r\n", | |
'content' => $data, | |
'timeout' => 10 | |
) | |
); | |
$context = stream_context_create($opts); | |
$result = file_get_contents('http://segment.sae.sina.com.cn/urlclient.php', false, $context); | |
$this->ajaxReturn($result,'JSON'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment