1.发送POST请求,携带json数据
public static function doPost2($url, array $params){$options = array('http' => array('method' => 'POST','content' => json_encode($params),'header' => "Content-Type: application/json\r\n" ."Accept: application/json\r\n"));$context = stream_context_create($options);$result = file_get_contents($url, false, $context);$response = json_decode($result, true);return $response;}
