Send SMS with PHP.

php-smsRecently I had a customer’s requirement to send an sms from his web portal.

The SMS gateway that he was using didn’t had that meaningful documentation.After planning on how do I connect to the SMS Gateway , I decided to use PHP cURL.

PHP cURL is a very efficient and powerful library that allows you to connect and communicate to different servers.For more information on cURL visit http://www.php.net//manual/en/book.curl.php .

The below code connects to the SMS gateway and then sends the message.

$url = "http://smsurl/sms1"; // URL of the SMS Gateway
$curl_connection = curl_init($url); //Initialize curl handle
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); //Set the post variables like username , password , sms text etc.
$result = curl_exec($curl_connection); //run the whole process and return the response
curl_close($curl_connection);  //close the curl handle

In the above code first the connection to the SMS Gateway is made.
Then the variables like username,password etc is passed.
These parameters and url are given by the SMS Gateway Provider.
The URL is then executed and finally the connection with the Gateway is closed.

 

 

allows you to connect and communicate to many different types of servers.. – See more at: http://goyal1989.blogspot.in/2011/06/how-to-send-sms-to-mobile-using-php.html#sthash.RDvKIBms.dpuf
very impressive library that allows you to connect and communicate to many different types of servers – See more at: http://goyal1989.blogspot.in/2011/06/how-to-send-sms-to-mobile-using-php.html#sthash.RDvKIBms.dpuf
very impressive library that allows you to connect and communicate to many different types of servers – See more at: http://goyal1989.blogspot.in/2011/06/how-to-send-sms-to-mobile-using-php.html#sthash.RDvKIBms.dpuf

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s