Last active
February 22, 2016 07:32
-
-
Save bakyeono/e8943a719f3ef5257be7 to your computer and use it in GitHub Desktop.
CURL GET & POST in PHP
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 curl_get($url) { | |
$curl = curl_init(); | |
curl_setopt_array($curl, array ( | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_HEADER => false, | |
CURLOPT_URL => $url, | |
CURLOPT_USERAGENT => 'useragent' | |
)); | |
$response = curl_exec($curl); | |
curl_close($curl); | |
return $response; | |
} | |
function curl_post($url, $params) { | |
$curl = curl_init(); | |
curl_setopt_array($curl, array ( | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_HEADER => false, | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => $params, | |
CURLOPT_URL => $url, | |
CURLOPT_USERAGENT => 'useragent' | |
)); | |
$response = curl_exec($curl); | |
curl_close($curl); | |
return $response; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage