2016-06-09 42 views
-1

我有一個PHP表單,它使得點擊sumbit按鈕的ajax調用來保存數據庫中的數據。我想調用短信API來發送這些細節點擊相同的提交按鈕。我怎麼做?我正在使用http://sms.hspsms.com/使用短信發送API點擊按鈕

這裏是腳本這需要數據annd其保存到數據庫:

<script> 
    $(function() { 
     $('#user-form').on('submit', function(e) { 

       $.ajax({ 
         type: 'post', 
        url: './user-details.php', 
        data: $('#user-form').serialize(), 
        success: function() { 
         alert('SUCCESS'); 
        } 
       }); 
       e.preventDefault(); 
      }); 
     });  
    </script> 

在哪裏使用SMS API,如:

http://sms.hspsms.com:/sendSMS?username=swati&message=XXXXXXXXXX&sendername=XYZ&smstype=TRANS&numbers= & apikey = XXXXXX

發送詳情進入在形式中。

編輯:我找到了解決辦法,它發佈爲答案。

+0

請提供您的一些測試代碼是行不通的。 – vitorio

回答

0

我做到了用這個:

$url = "http://sms.hspsms.com:/sendSMS"; 
     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL, $url); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=xxx&password=xxx&to=XXXXX&message=' . $phone . '&sendername=xxx&smstype=TRANS&numbers=xxxx&apikey=xxx'); 
     curl_setopt($ch, CURLOPT_POST, 1); 
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     $result = curl_exec($ch); 
     echo $result; 

用戶details.php內

0

我不太明白,但如果你想發送短信(短信),那麼這裏是如何。你不需要任何API來發送短信!將此代碼與其他代碼一起插入數據庫。

mail($number.'@'.$provider, '', $message, $headers); 

這裏是常用提供者列表。

Verizon無線 - vtext.com

維珍移動 - vmobl.com

Alltel公司 - sms.alltelwireless.com

ATT - txt.att.net

Boost Mobile公司 - sms.myboostmobile.com

Republic Wireless - text.republicwireless.com

疾跑 - messaging.sprintpcs.com

的T-Mobile - tmomail.net

美國行動通訊 - email.uscc.net

亞當Khoury的覆蓋它here在DevelopPHP.com。