//POST请求
//参数1是请求的url
//参数2是发送的数据的数组
//参数3是其他POST选项
public static function POST($url, array $post = array(), array $options = array(), $timeout = 10)
{
$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => $timeout,
CURLOPT_POSTFIELDS => http_build_query($post),
CURLOPT_SSLVERSION => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 2
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
$result = curl_exec($ch);
if ($result === false)
{
Yii::log("POST ERROR:" . curl_error($ch));
}
curl_close($ch);
return $result;
}
$url = 'https://www.baidu.com/xxxxx/xxxx/xxxx';
$params = array('aaa'=>'sadflcy123cb2234rlsdh213asd','admin_id'=>1,'token'=>'641iqtu8uu95t5moe5trf98a12','shop_id'=>3,'version'=>'app');
$result = $this->post($url,$params);