123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- function CURLrequestGET($url, $customHeaderStringArray='', $params = [])
- {
- $headers = array("Content-Type: application/json", "Accept:application/json");
- foreach ($customHeaderStringArray as $item) {
- $headers[] = $item;
- }
- $curl = curl_init($url);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- $result = curl_exec($curl);
- curl_close($curl);
- return $result;
- // var_dump($result);
- // var_dump ($result == 'true');
- }
- function CURLrequestPOST($url, $customHeaderStringArray='', $params = [])
- {
- $headers = array("Content-Type: application/json", "Accept:application/json");
- foreach ($customHeaderStringArray as $item) {
- $headers[] = $item;
- }
- $jsonEncoded = json_encode($params);
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_TIMEOUT, 60);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonEncoded);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- $result = curl_exec($curl);
- curl_close($curl);
- return $result;
- // var_dump($result);
- }
|