banner



How To Create Ideamart App

In this tutorial, we're gonna be learning how to create a Dialog Ideamart SMS Application, using Dialog Ideamart SMS API.

So, this will be an Ideapro application. For the programming part, we'll be using PHP. So, we're using Dialog Ideamart PHP SDK for this project.

For the simplicity, this tutorial only covers Developing an Ideamart SMS application and Running it on Idemart simulator. In a later tutorial we'll be covering how to Migrate the app to a live server and Provision the application and make it live.

If you have no idea what Ideamart is or how Ideamart work, I'd suggest to follow this short article first.  Otherwise you're good to go.

What are we creating ?

First of all, let's get to know what we're up to. We're creating a simple News Alert application. Whenever, you run the application, an SMS will be sent to all the subscribed users. That way, you can send news alerts to the users.

(Please note that this article is a beginner article. So, the explaining will be done with minimum complexity. )

So, here we have to use Ideamart SMS API for sending SMS messages.

01. Preparing the project environment

Ok, it's time to do some coding.

First, download Ideamart Developer Bundle and PHP SDK from their official website.

Once the all the files downloaded, create the project folder in the localhost directory and include the PHP SDK files inside it. The following figure will explain the file structure.

├── myapp | ├── lib //SDK Files | └──── caas | └──── lbs | └──── sms | └──── ussd | ├── app //Your application  | └──── index.php

So, our application logic goes in the index.php file inside the app folder.

02. Writing the application

Open up index.php file and let's write the code.

First we need to include the SDK files in our application script.

include_once '../libs/sms/SmsReceiver.php'; include_once '../libs/sms/SmsSender.php';        

Also, there should be a way to log the errors the app faces. Because that'll help us to investigate what's wrong in error situations.

            ini_set('error_log', 'app-error.log');        

Alright now let's create a new SmsSender object with the server URL.

          Localhost server URL          - https://localhost:7443/sms/send        
            $sender = new SmsSender("https://localhost:7443/sms/send");        

Alright, next we need set these arguments in order to send the SMS.

            $applicationId = "APP_000001"; //App ID given when provisioning the app. Not applicable when running on simulator. $encoding = "0"; $version = "1.0"; $password = "password"; $sourceAddress = "77000";  //Name that appears as SMS address.Not applicable when running on simulator. $deliveryStatusRequest = "1"; $charging_amount = ":15.75"; $destinationAddresses = array("tel:94771122336"); $binary_header = ""; $responseMsg = "News Alert : Prime minister stepping down"; // SMS content        

Actually some of these arguments do not actually matter as we're running this app on the simulator. You'll understand what they really mean when you're making this application live. So, leave these values as they are for now.

Alright, now we're calling the this method to send the SMS with the above arguments.

            $sender->sms($responseMsg, $destinationAddresses, $password, $applicationId, $sourceAddress, $deliveryStatusRequest, $charging_amount, $encoding, $version);        

And don't forget to wrap the code in a try catch block for handling exceptions.

Complete source code

So, this is the complete version of the SMS application we've just build.

include_once '../libs/sms/SmsReceiver.php'; include_once '../libs/sms/SmsSender.php';  ini_set('error_log', 'sms-app-error.log');  try {  $sender = new SmsSender("https://localhost:7443/sms/send");  $applicationId = "APP_000001"; $encoding = "0"; $version = "1.0"; $password = "password"; $sourceAddress = "77000"; $deliveryStatusRequest = "1"; $charging_amount = ":15.75"; $destinationAddresses = array("tel:94771122336"); $binary_header = "";  $responseMsg = "News Alert : Prime minister stepping down"; $sender->sms($responseMsg, $destinationAddresses, $password, $applicationId, $sourceAddress, $deliveryStatusRequest, $charging_amount, $encoding, $version);  }catch (SmsException $ex) { //throws when failed sending or receiving the sms error_log("ERROR: {$ex->getStatusCode()} | {$ex->getStatusMessage()}"); }        

Alright, we just developed our very first Ideamart SMS application. Now it's time to run this appliction.

03. Running the SMS App on Idemart Simulator

Inside Ideamart developer bundle, you can find the Ideamart Simulator. Possibly in two versions. Pick a version and go inside the folder. Inside the bin folder, you can find the binary file that need to be executed to start the Ideamart simulator.

To start the simulator, open up the Windows CMD and CD into this location. Then type,

sdp-simulator.bat console

Then you'll see the simulator is starting…

Please note that you need to have JDK (Java Development Kit) installed and properly configured by setting the Environment variables.

Alright, keep the CMD as it is to keep the simulator running.

Now, type on the web browser…

http://localhost:10001

It'll open up the Ideamart Simulator on the browser

Ideamart Simulator User Interface

Now, run your SMS application we developed on the web browser by typing…

http://localhost/myapp/app/index.php

That's it. Now check the simulator mobile screen and you'll see your message is there.

Summary

In this tutorial, we learned how to develop a simple Ideamart SMS application and learned how to run it on Ideamart simulator.

In the next article, we'll be learning how to migrate this application to a live server, provision your app and run it on your actual mobile phone instead of the simulator.

So, thanks for taking time and see ya!

How To Create Ideamart App

Source: http://coderaweso.me/create-dialog-ideamart-sms-application/

Posted by: brooksthenat1986.blogspot.com

0 Response to "How To Create Ideamart App"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel