Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.