2017-09-01 13 views
0

PHPコードを使用してオンラインSMSを送信

私はPHPには新しいですが、すでに作成されているニュースレター通知を補うためにSMSプラットフォーム/通知を私のウェブサイトに作成しようとしていますが、私は、複数の変数を初期化して、 PHPコード。手順は以下の通りです:ステップ1でと場合は、上記の行ったよう

//i favour if...elseif over the switch method 
//to declare the gateways variables 

//step one. declaring gateways variables 

$us_ca = array ('@txt.att.net', '@smscellular.com', '@more_gateways'); 
$nig = array ('@smsairtel.ng.com', '@more_gateways'); 
$gha = array ('@txt.mtn.com.gh', '@more_gateways'); 
.................................................. 

//note that the gateways are not correct but only cited as samples. 
// i use more_gateways to represent others i couldn't write 
// because of time and space 
//step two. where the sms gets delivered. 

if zip_code == '+1' { 
    email = '$telephone$us_ca', '$zip_code$telephone$us_ca'; //telephone 
    var for user's telephone, i create a second because some gateways 
    requires the country zip code. 
} elseif zip_code == '+234'{ 
    email = '$telephone$nig', '$zip_code$telephone$nig';     
} elseif zip_code == '+233'{ 
    email = '$telephone$gha', '$zip_code$telephone$gha';     
} 
........................................................ 
//note that i am targeting almost 90 countries. 

は、今私が知りたいすべてが、それはしても大丈夫です場合は、複数のVAR私は第二段階のISN」を行った方法を初期化する配列varにゲートウェイを宣言されていますt悪い。

個々の電話番号が特定の国で送信されるユーザに固有の番号であるため、各SMSはアレイのすべてのゲートウェイに同時に送信されるため、SMSはユーザだけに配信できる最初にすべてのゲートウェイに着きますが。

ありがとうございます。

+0

PHPから直接SMSを送信することはできません。あなたはtwilioまたはsmsghを試すことができます –

+0

私はそれがPHPを介してSMSを送信することが可能であることを確認したオンライン投稿を見たと思う。あなた自身のために見るためにオンラインで徹底的なチェックをしてください。実際には、私は私の研究を通じてメソッドを持っていましたが、一度にゲートウェイ(またはゲートウェイの配列)に電子メールを送ることができると言われていますが、私はそのインスタンスにvarを追加できるかどうかを知りたいと思います。以下のように入力してください: if zip_code == '+1' { email = '$ zip_code。= $ telephone。= $ us_ca' } ご回答ありがとうございます。 – test

+0

これをチェックしてください。 https://code.tutsplus.com/tutorials/how-to-send-text-messages-with-php--net-17693 –

答えて

3

コールSMSを送信するための簡単なPHPの関数でのSMS RestApi:

function CURLsendsms($number, $message_body){ 
$api_params = $api_element.'?apikey='.$apikey.'&sender='.$sender.'&to='.$mobileno.'&message='.$textmessage; 
$smsGatewayUrl = "http://springedge.com"; 
$smsgatewaydata = $smsGatewayUrl.$api_params; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_POST, false); 
curl_setopt($ch, CURLOPT_URL, smsgatewaydata); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$output = curl_exec($ch); 
curl_close($ch); 
// Use file get contents when CURL is not installed on server. 
if(!$output){ 
$output = file_get_contents($smsgatewaydata); 
} 
} 

また、あなたは、SMS http://www.phpclasses.org/package/9522-PHP-Send-SMS-messages-with-Spring-Edge-API.html

を送信するためにPHPのクラスを使用することができます上記のクラスに2つのファイルがあります

    は、
  • sendsms.php - smsゲートウェイを呼び出すクラスファイルrestAPI
  • test.php - sms関数をテストするサンプルファイル。

このクラスでは、スプリングエッジのsmsゲートウェイプロバイダAPIを使用して、RestapI urlおよびparamsを要件に応じてカスタマイズできます。

+0

あなたの返事に感謝しますが、問題は私が有料のサービスを使いたくないということですプラットフォームと私はサードパーティのアプリやウェブサイトなしで行うことができれば、より良い。あなたが提供したSMSゲートウェイのウェブサイトが有料のシステムだと思われますか? – test

+0

@test各SMSはオペレータに課金されるため、無料のSMSサービスはありません。あなたは最小限のパッケージのために行くことができます – BSB

関連する問題