Jump to content

cURL Calls


Hellbringer2572

Recommended Posts

Hi,

Is it possible to return information on a cURL call. for example i want to kind of make my own API for my website cn i make a cURL call to my server and return data back to the client or is cURL just to send data.

 

if cURL is just to send data what is another method to send a request and receive data back on the call?

 

Thanks

Mike

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

ok, i tried what i thought would work and it didnt here is the code

 

Call

function testFun()
{
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://192.168.0.1/test/curl.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_POSTFIELDS,
			"test1=1&test2=0");

$returnDate = curl_exec($ch);

curl_close ($ch); 

echo $returnDate;
}

 

Server to reutn data

 

$var1 = $_POST['test1'];
$var2 = $_POST['test2'];

if($var1 == "1")
{
return "one was selected";
}
elseif($var2 == "1")
{
return "two was selected";
}

 

thanks

Mike

Link to comment
https://forums.phpfreaks.com/topic/210762-curl-calls/#findComment-1099670
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.