Please disable your adblock and script blockers to view this page

Search this blog

Monday 20 October 2014

Send SMS from Oracle ADF Application using Horizon SMS API

This post is about using SMS API to send SMS text to mobile from an Oracle ADF application
there are various SMS Gateway to send SMS using java and all java API's can be used with Oracle ADF

here i am using sms horizon (a bulk sms provider in india) see this SMS API integration with Java and Oracle ADF, follow the steps
First create an account with SMS Horizon - or User Login- SMS Horizon

you can purchase a trial package to test your code, they provide 200 sms for Rs 25 only. So After purchasing trial pack you will get and API Key and username

Login to your account and see your dashboard-

you will see your API key in this type of box-

Now first step is complete and second and last step is implement code in your managed bean
you can find Sample API files (code to use API in Java, C#, PHP etc) from there

So for this i have a created a Fusion Web Application and a page in it

created a managed bean and actionListener for this Send button
this url is used to send sms and it returns msgId of sent message******&apikey=*****8&mobile=xxyy&message=xxyy&senderid=xxyy&type=txt

See the ActionListener code -

    /**Method to send SMS using SMS Horizon API
     * @param actionEvent
    public void sendSMSAction(ActionEvent actionEvent) {
        // get mobile number value using component binding
        if (mobNoBind.getValue() != null) {
            // Replace with your username
            String user = "userId";

            // Replace with your API KEY (We have sent API KEY on activation email, also available on panel)
            String apikey = "your_api_key";

            // Replace with the destination mobile Number to which you want to send sms
            String mobile = mobNoBind.getValue().toString();

            // Replace if you have your own Sender ID, else donot change
            String senderid = "WEBSMS";

            // Replace with your Message content
            String message = "SMS API -Oracle ADF";

            // For Plain Text, use "txt" ; for Unicode symbols or regional Languages like hindi/tamil/kannada use "uni"
            String type = "txt";

            //Prepare Url
            URLConnection myURLConnection = null;
            URL myURL = null;
            BufferedReader reader = null;

            //encoding message
            String encoded_message = URLEncoder.encode(message);

            //Send SMS API
            String mainUrl = "";

            //Prepare parameter string
            StringBuilder sbPostData = new StringBuilder(mainUrl);
            sbPostData.append("user=" + user);
            sbPostData.append("&apikey=" + apikey);
            sbPostData.append("&message=" + encoded_message);
            sbPostData.append("&mobile=" + mobile);
            sbPostData.append("&senderid=" + senderid);
            sbPostData.append("&type=" + type);

            //final string
            mainUrl = sbPostData.toString();
            System.out.println("URL to Send SMS-" + mainUrl);
            try {
                //prepare connection
                myURL = new URL(mainUrl);
                myURLConnection = myURL.openConnection();
                reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
                //reading response
                String response;
                while ((response = reader.readLine()) != null) {
                    //print response
                //finally close connection

            } catch (IOException e) {

    public void setMobNoBind(RichInputText mobNoBind) {
        this.mobNoBind = mobNoBind;

    public RichInputText getMobNoBind() {
        return mobNoBind;

you can check status of each SMS in your account that it is delivered of not, other than this you can also check status of msg in your code also using this url*****&apikey=*********&msgid=xxyy

pass msgId returned from previous url and it will return you status of message as- PENDING , DELIVERED etc
see imports used in code-



import javax.faces.event.ActionEvent;


Thanks :) Happy Learning


  1. Hi Ashish,

    I tried with your example but its saying as "response:ERROR: APIKEY is missing

    response:null" can you help what may be the reason for this I given api As "URL to Send SMS:****&apiKey=********&mobile=*****&message=This_Short_Mesage_from_Oracle_ADF_Application&senderid=*****&type=txt"


    1. Hi Hari

      First you have register with SMS Horizon to get API Key and then use that key in url


  2. I decided to try to do it, but got an error and realized that it was not for me. It is best to use the services of these guys This will bring new customers and make great remarketing, which will bring additional revenue. This is great practice for a young business.

  3. Bulk SMS just means sending an extensive volume at once. Bulk SMS works correspondingly with the way we send SMS from our cell phones or pc by using Top 5 Bulk SMS Service Provider in India.