Created
October 12, 2022 03:52
-
-
Save jyxjjj/de36b5fdc45ff3f738066d88288dedea to your computer and use it in GitHub Desktop.
cURL PHP GET POST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function GET($url, $user_agent = 'CURL', $proxy_type = CURLPROXY_SOCKS5_HOSTNAME, $proxy = null, $header = null, $timeout = 10) | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); | |
$header != null && curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | |
$proxy != null && curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy_type); | |
$proxy != null && curl_setopt($ch, CURLOPT_PROXY, $proxy); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); | |
curl_setopt($ch, CURLOPT_HEADER, false); | |
$file_contents = curl_exec($ch); | |
curl_close($ch); | |
return $file_contents; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function POST($url, $post_data = null, $user_agent = 'CURL', $proxy_type = CURLPROXY_SOCKS5_HOSTNAME, $proxy = null, $header = null, $timeout = 10) | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
$post_data != null && curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); | |
$user_agent != null && curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); | |
$header != null && curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | |
$proxy != null && curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy_type); | |
$proxy != null && curl_setopt($ch, CURLOPT_PROXY, $proxy); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); | |
curl_setopt($ch, CURLOPT_HEADER, false); | |
$file_contents = curl_exec($ch); | |
curl_close($ch); | |
return $file_contents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment