Skip to content

Instantly share code, notes, and snippets.

@weishai
Created May 31, 2013 18:45
Show Gist options
  • Save weishai/5687049 to your computer and use it in GitHub Desktop.
Save weishai/5687049 to your computer and use it in GitHub Desktop.
curl请求实例
<?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