-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp.php
38 lines (35 loc) · 923 Bytes
/
http.php
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
38
<?php
$url= $_REQUEST['url'];
$type= $_REQUEST['type'];
$data= $_REQUEST['data'];
$callback= $_REQUEST['callback'];
$postdata = http_build_query($data);
$options =null;
if($type=='get'){
$options = array(
'http' => array(
'method' => 'get',
'content' => $postdata,
'timeout' => 15 * 60 // 超时时间(单位:s)
)
);
}else{
$options = array(
'http' => array(
'method' => 'post',
'header' => 'Content-Type: application/json; charset=utf-8',
'content' => $data,
'timeout' => 15 * 60 // 超时时间(单位:s)
)
);
}
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if($callback!=""){
echo $callback."(";
}
echo $result;
if($callback!=null){
echo ")";
}
?>