New cURL based on another cURL result


#1

Hello guys,
I'm new in PHP and i want to call another external API using cURL,
with this piece of code everything is good and the result is what i need.

$curl = curl_init();
		curl_setopt_array($curl, array(
		    CURLOPT_RETURNTRANSFER => 1,
		    CURLOPT_URL => $api_URL,
		    CURLOPT_USERAGENT => 'Token cURL Request'
		));
		$resp = curl_exec($curl);
		curl_close($curl);

but problem starts when i want to call a new cURL base on the previous cURL after i get result.
I think i need wait for first one to complete before starting a new one but i'm beginner in php and i don't know how i can write that.


#2

Doesn't curl_exec() not return until it has retrieved the requested resource? I can't see any mention of it being asynchronous.

What problems do you have when you try to call it a second time?


#3

Plain cURL is processed like every other PHP script, from top to bottom. So just make another call.


#4

Thanks for your reply , i found the problem it was a silly mistake in syntax and the log error didn't mention to that line


#5

It most definitely is not asynchronous


#6

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.