CodeIgniter Forums
Sms API - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Sms API (/thread-56964.html)



Sms API - El Forum - 02-03-2013

[eluser]SamoualSys[/eluser]
i have sms api its not working its give me nothing can any one help me in that
this the code for the sms api
Code:
class Sms_api {  
        //change this to the actual user and password  
        private $username = 'myusername';  
        private $password = 'password';  
        private $sendname   = 'sendername';  
        private $url      = 'http://www.mydomain.net/api/sendSMS.php';
  private $encode ='utf-8';
        public function send_sms( $phone, $text ){  
            $url = $this->url . '?userid=' . $this->username .  
            '&password;=' . $this->password .  
            '&to;=' . $phone .  
            '&text;=' . urlencode( $text ).
   '&sender;=' . $this->sendname .
   '&encoding;=' . $this->encode ;  
            $r = @file( $url );  
            $res = substr( $r[0], 9, 0);  
            if( $res == '0' ){  
                return true;  
            }  
            return flase;  
        }
if its success you get this in the page
Code:
Error : 0
MessageID : 5
iam sending using this controller for testing
Code:
$this->load->library('sms_api');
$data['phone'] = '123222222';
$data['text'] = 'you have got sms in your inbox';
    $this->sms_api->send_sms( $data['phone'], $data['text'] );
    $this->render();
please help me in that


Sms API - El Forum - 02-03-2013

[eluser]Unknown[/eluser]
Are you aware that the api URI in the code is a sedo parked domain?
http://cl.ly/image/240A221E3f10


Sms API - El Forum - 02-04-2013

[eluser]SamoualSys[/eluser]
i have changed the main URL and after i read your post i have update my post with something will not led people to think about the URL thanks a lot for your post .


Sms API - El Forum - 02-09-2013

[eluser]SamoualSys[/eluser]
the code is working now i have found that i mis read the api of the provider
i was writing
'&text;=' . urlencode( $text ).
while it should be '&msgtext;=' . urlencode( $text ).

also i have changed the code in the return value from true to show me the result of the url
'&msg;=' . urlencode( $text ).
'&sender;=' . $this->sendname .
'&encoding;=' . $this->encode ;
$r = @file( $url );
$res = substr( $r[0], 8, 1);
if( !$res == '0' ){
return false;
}

return $r;
}
}

thanks every one