php - Simply posting variables through GET in cURL -


So I'm trying to create a small API here, I will only send some information through the header (get paramat) And I'm not using any POST parameters here's the code that I've written.

  function sendSMS ($ message, $ number) {/ *** connection is the ultimate ** / *** *** Generate request parameters *** / $ service = "sms_api_call_receiver.php"; $ Number = "1212"; $ Message = "asas"; $ Result = sendPost ("https://www.domain.com/smsapp/". $ Service. "? Message =". Urlencode ($ message). "And number =". $ Number); Return result; } // function function sendPost ($ Url) {// initialization $ ch = curl_init (); // Set the parameter curl_setopt ($ ch, CURLOPT_URL, $ Url); // Return a variable instead of posting curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); // active post method // curl_setopt ($ CH, CURLOPT_POST, 1); // request // curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ strRequest); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, 0); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYHOST, 0); // execute the connection $ result = curl_exec ($ ch); // turn it off / return curl_error ($ ch); Curl_close ($ ch); Return result; }   

On the receiver file, I have this code: -

  if (isset ($ _ GET ['message'])) {true; } Other {return "12212"; }   

But when I do the test, I get the output: -

  string "'(length = 0)   

what am I doing wrong here?

Troubleshooting I tried to see that curl_error but I could not see anything here any suggestions would be useful.

Are you sure there is something wrong there? The script (sms_api_call_receiver.php) returns true if the $ _ GET ['message'] is set (in your test example) and stops the execution.

Because this HTTP request, and the response is empty, you will find the result as 0 length in the form with the sendSMS () function string.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -