Download core/app/Lib/CurlRequest.php from pnacorp/codeplus: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/pnacorp/codeplus/resolve/main/core/app/Lib/CurlRequest.php
- Command line
-
hf download hf://pnacorp/codeplus/core/app/Lib/CurlRequest.php
-
curl -L -o CurlRequest.php https://huggingface.co/pnacorp/codeplus/resolve/main/core/app/Lib/CurlRequest.php
1.27 kB
| namespace App\Lib; | |
| class CurlRequest | |
| { | |
| /** | |
| * GET request using curl | |
| * | |
| * @return mixed | |
| */ | |
| public static function curlContent($url,$header = null) | |
| { | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
| if ($header) { | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | |
| } | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $result = curl_exec($ch); | |
| curl_close($ch); | |
| return $result; | |
| } | |
| /** | |
| * POST request using curl | |
| * | |
| * @return mixed | |
| */ | |
| public static function curlPostContent($url, $postData = null,$header = null) | |
| { | |
| if (is_array($postData)) { | |
| $params = http_build_query($postData); | |
| } else { | |
| $params = $postData; | |
| } | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
| if ($header) { | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | |
| } | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_POST, true); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $params); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $result = curl_exec($ch); | |
| curl_close($ch); | |
| return $result; | |
| } | |
| } | |