Created
October 2, 2012 11:37
-
-
Save lemmycaution/3818359 to your computer and use it in GitHub Desktop.
php curl proxy example
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
<? | |
# curl icin POST degerlerini tutucak string variable | |
$cpost = ""; | |
# HTTP post verilerini geciriyoruz | |
foreach($_POST as $key=>$value){ | |
$curl_post .= $key."=".$value."&"; | |
} | |
$cpost = substring($cpost,0,strlen($cpost)-1); | |
# curl init ve cesitli post icin gerekli ayarlar | |
$ch = curl_init("http://links.mailing.greenpeace.org/servlet/UserSignUp?f=726648&postMethod=HTML&m=0&j=MAS2"); | |
curl_setopt($ch, CURLOPT_POST ,1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS ,$cpost); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,0); | |
curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL | |
# post isleminden geri donen response | |
$response = curl_exec($ch); | |
# curl objesini kapatiyoruz ki memory vs server sismesin | |
curl_close($ch); | |
# response, burda geri donen response a gore JSON, XML, HTML content-type header lari eklenebilir | |
echo $response; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment