Crowny Javascript Api

 

The Crowny JavaScript api allows you to quickly and easily write JavaScript based sms application. The api communicates with the gateway via the HMTL 5 WebSocket and message  are transferred in Json Format

NOTE: The API currently only supports the WebSocket Module so to use it enable the WebSocket Module find out how here

Sample Usage

Connect to the gateway (WebSocket Module Needs to be enabled)

SMS.connect("localhost","5001");

Send SMS

SMS.SendSMS("1234567","Hello World");

Receive SMS

function OnRecieve()

{

alert("Message:"SMS.Message+"Sender:"+SMS.Sender);

}

Varables

Password
Description
Stores the password used to connect to the websocket module if enabled on the gateway
Usage
SMS.Password = "sample password";
can also be set when connecting to the server so this is set only once
SMS.connect("localhost","5001","Password Goes here");
 
Message
Description
Stores The text value of every new message that is received
Usage
alert(SMS.Message)
 
Sender
Description
Stores the phone number of the sender of every new message received
Usage
alert(SMS.Sender)
 
MessageType
Description
Stores the message type of every new message received available type
INBOUND
FACEBOOK
STATUSREPORT
Usage
alert(SMS.MessageType)
 
FBUser
Description
Stores the facebook username of the user who made the Wall/Timeline post of every new message received only applicable if the message is from facebook
Usage
alert(SMS.FBUser)
 
FBPostid
Description
Stores the id of the Facebook Wall/Timeline post of every new message received only applicable if the message is from facebook
Usage
alert(SMS.FBPostid)

Functions

El (Element_ID)

Description
Returns the id of the element provided  
Usage
alert (El("phone").value);
 
connect (Host,Port,Password)
Description
Establishes a connection with the Crowny Websocket Module
Usage
SMS.connect("localhost","5001");
1st Parameter is the host/IP of the gateway
2nd Parameter is the Port the WebSocket module is running on
​if password is enabled
SMS.connect("localhost","5001","password");
 
OnConnect()
Description
This is triggered when a connection is successfully established with the gateway 
Usage
function OnConnect()
{
//write some code here
}
 
OnReceive()
Description
This is triggered when a message is received from the gateway 
Usage
function OnReceive()
{
//write some code here
}
 
OnDisconnect()
Description
This is triggered when the connection with the gateway is closed 
Usage
function OnDisconnect()
{
//write some code here
}
 
Display (Divid)
Description
Display the received message in the DIV provided
Usage
SMS.Display('container');
result looks like this
crowny javascript sms api
 
SendSMS (PhoneNo, Message, FBUser, FBPostid)
Description 
Send out a text message to the gateway way,
if the  FBUser is provided the message will be posted on the Facebook users wall/timeline use me to post on your wall
if FBPostid is provided the message will be posted as a comment on the facebook post
Usage
SMS.SendSMS(phoneno,message);
Post on your Facebook Timeline
SMS.SendSMS(" ","Test Message from crowny", "me");
Post as a comment on facebook wall post
SMS.SendSMS(" ","Test comment from crowny","","12345_1234566");
 
ShowStatus(Divid)
Description
Display the connection status between the application and the gateway in the Div provided
available status
Connected
Disconnected
you can set a custom value with the SetStatus(Textvalue) function 
Usage
SMS.ShowStatus("log");
 

 

Free counters!