Hellbringer2572 Posted August 15, 2010 Share Posted August 15, 2010 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 More sharing options...
MadTechie Posted August 15, 2010 Share Posted August 15, 2010 curl_exec returns the page you called! Link to comment https://forums.phpfreaks.com/topic/210762-curl-calls/#findComment-1099517 Share on other sites More sharing options...
Hellbringer2572 Posted August 15, 2010 Author Share Posted August 15, 2010 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 More sharing options...
MadTechie Posted August 15, 2010 Share Posted August 15, 2010 you need to use echo instead of return ie echo "one was selected"; Link to comment https://forums.phpfreaks.com/topic/210762-curl-calls/#findComment-1099674 Share on other sites More sharing options...
Hellbringer2572 Posted August 15, 2010 Author Share Posted August 15, 2010 thank you Mike Hellbringer Link to comment https://forums.phpfreaks.com/topic/210762-curl-calls/#findComment-1099678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.