php - Simple http call via cURL returns false -
so i'm trying create little api via http post method. i'm facing little problems here. have code i'm using create http phone call domain.com/smsapp/service...., but, response :- boolean false might wrong here? have no thought can go wrong here.
function sendsms($message,$number) { $id = "dogbag"; $service = "sms_api_call_receiver.php"; $userip = $_server['remote_addr']; /*** build request parameters ***/ $request="send-sms"; $u="http://www.domain.com/smsapp/$service?id=$id" . "&message=" . $message . "&number=$number" . "&ip=" . $userip; $result = sendpost($u, $request); var_dump($u); homecoming $result; }//function function sendpost($url, $strrequest) { // initialisation $ch=curl_init(); // set parameters curl_setopt($ch, curlopt_url, urlencode($url)); // homecoming variable instead of posting straight 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, 2); curl_setopt($ch, curlopt_ssl_verifyhost, 2); // execute connexion $result = curl_exec($ch); // close curl_close($ch); homecoming $result; }
sms_api_call_receiver.php
if(isset($_get['message'])) { mail("myemail@gmail.com", "got", "message"); }
neither message, nor errors. boolean false. suggestion on appreciated.
try changing this: in function sendsms :-
$u="www.domain.com/smsapp/$service?id=$id" . "&message=" . $message . "&number=$number" . "&ip=" . $userip;
and in function sendpost:-
curl_setopt($ch, curlopt_url, "http://" . urlencode($url));
php curl
No comments:
Post a Comment