1,105,417 Community Members

Unable to send sms using Ozeking - Smsgateway

Member Avatar
rayidi
Junior Poster in Training
85 posts since May 2011
Reputation Points: 3 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
0
 
                                echo "<form action='' id='customForm' method='post'>";
                                echo "<div>";
                                    $mobile = $_SESSION['mobile'];
                                    echo "<label for='name'>From : $mobile</label>";
                                echo "</div>";
                                echo "<div>";
                                    echo "<label for='name'>Sender Mobile number</label>";
                                    echo "<input type='text' name='recipient' id='mobile' class='error'>";
                                    echo "<span id='nameInfo' class='error'> Mobile number must contain only 10 digits</span>";
                                echo "</div>";
                                echo "<div>";
                                    echo "<label for='email'>Message &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;your sms balance : {$udata['sms']}</label>";
                                    echo "<textarea onKeyDown='limitText(this.form.smessage,this.form.countdown,140);' onKeyUp='limitText(this.form.smessage,this.form.countdown,140);' maxlength='140' name='message' id='message'></textarea>";
                                    echo "<span id='emailInfo' class='error'> Message boy supports 140 charecters :P</span>";
                                echo "</div>";
                                echo "<div>";
                                echo "You have <input readonly type='text' id='limited' name='countdown' size='3' value='140'> characters left.</font>";
                                echo "</div>";
                                    echo "<div>";
                                        echo "<input type='submit' value='Send' name='send' id='send'>";
                                    echo "</div>";
                            echo "</form>";

Receiving in POST Method:

        if(isset($_POST["send"]))
                            {
                                $recipient = $_POST["recipient"];
                                $message = $_POST["message"];
                                if($recipient == "" || $message == "")
                                {
                                    echo "<div cloass='error'>are you kidding ? enter something to act</div>";
                                }
                                else
                                {
                                    $recipient = $_POST["recipient"];
                                    $message = $_POST['message'];

                                    $gateway = "http://127.0.0.1:8080/api?action=sendmessage&username=admin&password=admin&recipient=NNNNN&messagetype=SMS:TEXT&messagedata=MMMMM";
                                    $gateway = str_replace("NNNNN", $recipient, $gateway);
                                    $message = str_replace("", "+", $message);
                                    $gateway = str_replace("MMMMM", $message, $gateway);

                                    $r= new HttpRequest($gateway, HttpRequest::METH_POST);
                                    try
                                    {
                                        $r->send();
                                        echo "<div cloass='error'>Message sent to : $recipient</div>";
                                    }
                                    catch (HttpException $ex)
                                    {
                                        echo $ex;
                                    }
                                }
                            }

Am not able to send sms using this script, can any one find the error thanks in advance..

Member Avatar
cereal
Posting Virtuoso
1,710 posts since Aug 2007
Reputation Points: 461 [?]
Q&As Helped to Solve: 345 [?]
Skill Endorsements: 44 [?]
 
0
 

You should write more information, you get the data from the form? You still display the correct data after you do str_replace()? Have you tried to get response code? Right after r->send(); write:

try
{
    $r->send();
    echo $r->getResponseCode(); # so you know if the request reaches the gateway
    echo "<div cloass='error'>Message sent to : $recipient</div>";
}
Question Answered as of 1 Year Ago by cereal
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: