cjpt.php
675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
class cjpt{
/**
* 发送请求,POST
* @param $url 指定URL完整路径地址
* @param $data 请求的数据
*/
public static function requestWithPost($url, $data){
// json
$headers = array(
'Content-Type: application/json',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
}