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 Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 15, 2010 Share Posted August 15, 2010 curl_exec returns the page you called! Quote Link to comment 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 Quote Link to comment 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"; Quote Link to comment Share on other sites More sharing options...
Hellbringer2572 Posted August 15, 2010 Author Share Posted August 15, 2010 thank you Mike Hellbringer Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.