Mike
Mike

Reputation: 371

There is something wrong with my CURL script

I'm using a CURL script to basically recreate the process a user having to hit send on a form. I would like everything to run in the background but it never sends when this script executes.

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    "&shopId=".$ID."&encodedMessage=".urlencode($encodedMessage)."&signature=".$signature);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 
    "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

$result = curl_exec($ch); 

Is it perhaps not executing?

Upvotes: 3

Views: 216

Answers (2)

Frederic Bazin
Frederic Bazin

Reputation: 1529

curl is not a good option to emulate fork.

As soon as your current script stops, the curl request will be killed and probably the target url will also stop executing its own script.

you could use a cron or similar external process to run the curl requests and it would run with no interruption. It would also be helpful to queue up parallel requests.

Upvotes: 0

0xAli
0xAli

Reputation: 1059

Tested, working great.

Did you set the variable $url right?

Upvotes: 1

Related Questions