If you have sms-gateway-provider and have a user-id, password and api-url. Then folow this sample codes
<?php function sms_code_send($number='',$message='') { $username = 'user name'; $password = '*******'; $originator = 'sender name'; $message = 'Welcom to ......, your activation code is : '.$message; //set POST variables $url = 'http://exmaple.com/bulksms/go?'; $fields = array( 'username' => urlencode($username), 'password' => urlencode($password), 'originator' => urlencode($originator), 'phone' => urlencode($number), 'msgtext' => urlencode($message) ); $fields_string = ''; //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); return $result; } ?>
Question and answer is powered by AnsPress.io