Jump to content

cURL help


c_pattle

Recommended Posts

I have just installed cURL and am learn to use it but I'm not sure exactly what I am doing.  For example I have a page with this code on it. 

 

if($_GET['number'] == "6") {
    echo("<p>the number is six</p>");
}

 

Then I am trying to use cURL to send the number 6 to this page so that it returns "the number is 6".  However I am just getting an output of "1".  Below is the code I am using to try to get the output of "the number is 6". 

 

$ch2 = curl_init();

curl_setopt($ch2,CURLOPT_URL,'http://localhost/crawler/crawlertest.php');
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2,CURLOPT_POSTFIELDS,'number=6');
$return = curl_exec($ch2); 

echo ($return);

curl_close($ch2);

 

Thanks for any help

 

Link to comment
https://forums.phpfreaks.com/topic/216187-curl-help/
Share on other sites

$return is the return value of the operation, not the returned content if any.

 

curl_exec: Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.

 

You might only need to add this line before using curl_exec:

 

curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);

Link to comment
https://forums.phpfreaks.com/topic/216187-curl-help/#findComment-1123579
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.