Skip to content

Instantly share code, notes, and snippets.

@TechNinjaWeb
Created December 20, 2015 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TechNinjaWeb/2e4afbc80c7eb9f89205 to your computer and use it in GitHub Desktop.
Save TechNinjaWeb/2e4afbc80c7eb9f89205 to your computer and use it in GitHub Desktop.
PHP Curl Request Response
<?php
header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');
$string = parse_str($_SERVER["QUERY_STRING"]);
$curl = curl_init();
$timeout = 30;
$ret = "";
if ($_REQUEST["data"]) {
$data = $_REQUEST["data"];
}
if ($data) {
$url = utf8_decode(urldecode($data));
} else if ($_POST["data"]) {
$url = utf8_decode(urldecode($_POST["data"]));
}
$options = Array(
CURLOPT_URL => $url,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_MAXREDIRS => 20,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5",
CURLOPT_CONNECTTIMEOUT => $timeout,
CURLOPT_RETURNTRANSFER => 1
);
curl_setopt_array($curl, $options);
$response = curl_exec($curl);
?>
<?php
curl_close($curl);
echo $response;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment