Does anyone no if it is possible to store echoed results from a Curl script.
Example of script been submitted to:
\\some code to generate images using imagick and the post variables
$array = array(1,2,3,4,5,6,7,8,9);
$result = json_encode($array);
echo $result;
Example of Curl:
$id = 1;
$champ = array("product" => "1","id"=> $id,"occasion"=> $o,"field1" => "1991","field2" => "test","field3" =>"test1","field4" => "test2","field5" =>"test3","field6" =>"test4","field7" =>"test5","field8" =>"test6","test7");
foreach($champ as $key => $data){
$field_string .= $key."=".$data."&";
}
rtrim($field_string, "&");
$url = "http://www.test.com/website/script.php";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, count($champ));
curl_setopt($ch,CURLOPT_POSTFIELDS, $field_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
$result = curl_exec($ch);
$array = json_decode($result);
curl_close($ch);
var_dump($array);
If i var_dump($result) i get a bool(true) so i know that the script has executed correctly and the output shows on screen however i don't seem to be able to store the information into a variable to process.
Thank you in advance
curl_exec()should never returntruewhenCURLOPT_RETURNTRANSFERis turned on. Maybe the problem is there. Where can you view the output, in the 2nd PHP script or when you point your browser to the first one?