This repository was archived by the owner on Sep 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurlMethod.php
More file actions
53 lines (44 loc) · 1.34 KB
/
Copy pathcurlMethod.php
File metadata and controls
53 lines (44 loc) · 1.34 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
function curl_get_uri($uri, $method = 'GET', $calldata = NULL, $accept = 'application/json', $contentType = 'application/json')
{
include('vars.php');
$headers = array(
'Accept: ' . $accept,
'Content-Type: ' . $contentType
);
if (is_array($calldata)) {
$calldata = json_encode($calldata);
}
if($intern) {
$uri = $uri.'?intern=TIN';
}
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $uri);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
switch ($method) {
case 'GET':
break;
case 'POST':
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $calldata);
break;
case 'PUT':
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($handle, CURLOPT_POSTFIELDS, $calldata);
break;
case 'DELETE':
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
}
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if (empty($response) || empty($code)) {
return $response ? $response : $code;
}
$response = str_replace($adlibEnglish, $adlibDutch, $response);
return $response;
}
?>