Execute Php script through curl | execute php script using curl

<?php
$url = "url of script/ code page which we want to execute using curl";
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST,0);
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0);  // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  // RETURN THE CONTENTS OF THE CALL
$return = curl_exec($ch);

//write down execution code return data to txt file
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $return;
fwrite($fh, $stringData);
fclose($fh);
?>

Post a Comment

0 Comments