Skip to content

Commit

Permalink
Merge pull request #5 from manishmodi/master
Browse files Browse the repository at this point in the history
Adding incoming documentation
  • Loading branch information
manishmodi committed Apr 3, 2015
2 parents c377e69 + 8069cd3 commit f909881
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Sparrow SMS receives requests via a single standard endpoint as below:

**URL** : [api.sparrowsms.com/v2](http://api.sparrowsms.com/v2)

# 1.Outgoing
# 1. Outgoing
Our outgoing API enables you to send sms, get credits details.

## i. Send SMS
Expand All @@ -18,3 +18,8 @@ Outgoing or Push or MT (Mobile Terminated) messages are sent from Sparrow SMS Ga
Check available, consumed credits in Sparrow SMS account

[**Check documentation **](/outgoing_credits/)

# 2. Incoming
Our incoming API enables you to recieve sms, process request and reply back with reply.

[**Check documentation **](/incoming/)
53 changes: 53 additions & 0 deletions docs/examples_incoming.md
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
# Examples (Incoming SMS)

## Php

```
// STEP 1
// incoming request parameters
$from = $_GET["from"]; // sms sender
$to = $_GET["to"]; // shortcode
$keyword = $_GET["keyword"]; // first word
$text = $_GET["text"]; // the complete text
$timestamp = time();
// STEP 2
// build your logic on how to respond the incoming request
switch($keyword){
case "one":
$reply = "You (". $from .") have been subscribed to campaign one";
break;
case "two":
$reply = "You (". $from .") have been subscribed to campaign two";
break;
default:
$reply = "Invalid campaign name";
break;
}
// STEP 3
// may be you need to save the request to your own database
// @optional
mysql_connect("localhost", "username", "password");
mysql_select_db("sparrow_sms");
mysql_query("insert into logs_incoming
(`from`, `to`, `keyword`, `text`, `timestamp`)
values ('".mysql_real_escape_string($from)."',
'".mysql_real_escape_string($to)."',
'".mysql_real_escape_string($keyword)."',
'".mysql_real_escape_string($text)."',
'".$timestamp."'
)");
// STEP 4
// send reply back to Sparrow SMS
// This has to be STRICTLY 160 chars (max)
die($reply);
```
46 changes: 46 additions & 0 deletions docs/incoming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Receive SMS / Incoming / Pull / MO (Mobile Originated)

##Shortcode
Shortcode is four digit number to which user can send SMS from any telecom. Benefits of Shortcodes are:
1. Easy to remember
2. Provides direct connectivity to Telecom
3. Shortcode can have different tarrifs like (Rs. 1-5)

## Keyword
First word of SMS sent by user is Keyword, it is used to identify the action / service requested.

## Sub Keyword
Second Keyword of SMS sent by user is called Sub Keyword. Its optional and depends upon the campaign


## Parameters

**_Settings_**
```
URL : Public URL where the incoming SMS has to be forwarded.
Keyword : Keyword that has to be forwarded.
Shortcode : Shortcode to which, user has to send SMS.
Default Reply : Default response that has to be sent to user,
incase request to url fail.
```

**_Request_**

```
GET request is sent to the URL provided with following arguments:
from : Subscribers number sending SMS.
to : Shortcode to which subscriber has sent SMS.
text : Complete SMS sent by user.
keyword : Keyword of SMS sent.
```

## Response
URL must process the request and send text response of maximum 160 characters with status code 200 or 202. Incase of any other response code, default reply will be sent to user as SMS reply.

[**Proceed to examples**](/examples_incoming/)
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Sparrow SMS provides both **MT** and **MO** APIs and supports with integration w

`(Version 2.0)` API supports RESTFUL support.

##Contact Details:
**Email: [email protected]**
**Phone: 01-5522942 / 9802005008**
__ __

[Check the latest API Documentation](documentation)

[Jump to Examples](examples)
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pages:
- ['documentation.md', 'Documentation']
- ['outgoing_sendsms.md', 'Push SMS (MT)']
- ['outgoing_credits.md', 'Credits']
- ['incoming.md', 'Pull SMS (MO)']
- ['examples.md', 'Examples']
- ['examples_outgoing.md', 'Push SMS (MT) Examples']
- ['examples_credits.md', 'Credits Examples']
- ['examples_incoming.md', 'Pull SMS (MO) Examples']

0 comments on commit f909881

Please sign in to comment.