Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,198,799 members, 7,969,383 topics. Date: Tuesday, 08 October 2024 at 06:58 AM |
Nairaland Forum / Science/Technology / Webmasters / How To Integrate SMS Sending Into Your Application - A Tutorial (2676 Views)
I Want To Integrate Ecommerce Into My Entertainment Blog. I Need Advice Please / Popular Reasons Why Adsense Reject Your Application / How To Integrate "Payment With Airtime" Feature Into Your Web Applications. (2) (3) (4)
How To Integrate SMS Sending Into Your Application - A Tutorial by bakenda(m): 11:20pm On Jul 10, 2015 |
A lot of applications nowadays are sms-enabled. In this tutorial I'm going to show you how to integrate sms-sending capability into your applications, some of the common uses of sms in applications include: sending a custom message to a user after signing up, or after making a purchase on an ecommerce site, automatic birthday greetings and of course the familiar bank transaction alerts("Godwin",lol), there could be countless other creative uses, the idea is the same as we are going to see. [size=13pt]What you need[/size] Now, to sms-enable your application, you need access to an sms gateway api...and the documentation. An example of such is the one provided by Supertext: http://www.supertextng.com/api.php?username=[username]&password=[password]&destination=[destination]&message=[message]&sender=[sender] This is a RESTful HTTP API, you can consume it in whatever language you use. Here, we are going to be speaking PHP, but the principle is the same for all languages. Most sms api's are in this form. If you type that api url in a browser, something happens, an sms gets sent if everything is rigth, a response is returned in any case. Now, the question to ask is how do we open that url programatically i.e within an application. In the answer to that question lies the crux of the matter. [size=13pt]Filesystem functions and cURL to the Rescue[/size] The api url can be viewed as a resource or as a file with some content, when you open it, some textual content is returned as a response, that means we can use filesystem functions like file(), fopen(), file_get_contents() to programatically open the api url and achieve what we want. The cURL library can also be used to achieve the same end, and this seems to be what is often used in practice, but here we are going to take an illustrative example using the file() function. [size=13pt]An Example[/size] Let's say you want to send an sms automatically to users after they sign up for your application. The signup form essentially consists of the Name(name), Email Address(email), Password(password), and GSM Number(gsm) fields. You already have access to an sms gateway api. To make things neat, let's write a standalone function for sending sms that we can always call to get the job done. Here we go... <?php 1 Like |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by bakenda(m): 11:40pm On Jul 10, 2015 |
We have to urlencode() the message to take care of spaces between words, this is necessary when sending via url, otherwise only the first word gets sent. Let's save that in a file named myfunctions.php This is a simplistic function, it assumes a successful send operation as we didn't test if the sms was sent or not based on the api response. Api responses differ, we have to follow the documentation of the particular api we are using, I might write another sendsms funtion that takes this into account later based on the Supertext api. Now, to the signup code. <?php That's it folks, 'hope it's clear enough. The save_to_db() function is the function that saves the user details to your database, we assume it's included in the myfunctions.php file, we are not concerned with it's details here. Comments are welcome. Want to learn PHP programming in greater details? Click the link below: PHP training. **We need a real code highlighter here. How does one prevent "bracket semicolon from turning to a smiley? 3 Likes |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by nnamdiosu(m): 11:42pm On Jul 12, 2015 |
bakenda: nice tutorial bro. really appreciate it. but please in case its an asp application. how can i go about it using my php SMS api? thanks in advance |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by bakenda(m): 1:45am On Jul 13, 2015 |
nnamdiosu: Thank you. Well, the api is not a php api, it is not tied to any particular language, I think what you need to do is to look for the asp equivalents of those file system functions and use them as specified. |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by joseph1013: 3:27pm On Feb 09, 2016 |
Good stuff. Can you recommend a SMS gateway that is great and affordable? Urgent! |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by nnamdiosu(m): 3:48pm On Aug 17, 2016 |
bakenda: bro no vex abeg. how you take get this method... if(save_to_db($name,$email,$password,$gsm)) i cant see any where you declared it. thanks |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by nnamdiosu(m): 4:05pm On Aug 17, 2016 |
oh dont mind me. just saw what it stands for (submitting to the db). ive tried and it worked for me. thanks so much bro. |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by boro43(m): 3:03am On Dec 04, 2016 |
Please i need to learn more about this, its not working for me. |
Re: How To Integrate SMS Sending Into Your Application - A Tutorial by bakenda(m): 7:58am On Dec 17, 2016 |
boro43: Really.What exactly is the chalenge? |
(1) (Reply)
Who Is Hosting Nairaland.com Website? / Using Wordpress To Build A Website / Bloggers Connect
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38 |