Skip to content

Instantly share code, notes, and snippets.

@lemmycaution
Created October 2, 2012 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lemmycaution/3818359 to your computer and use it in GitHub Desktop.
Save lemmycaution/3818359 to your computer and use it in GitHub Desktop.
php curl proxy example
<?
# 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