Skip to content

Commit

Permalink
Merge pull request #4 from manishmodi/master
Browse files Browse the repository at this point in the history
Adding c# example
  • Loading branch information
manishmodi committed Dec 30, 2014
2 parents 2fda87b + d80d7a7 commit c377e69
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 10 deletions.
39 changes: 36 additions & 3 deletions docs/examples_credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```
curl -s http://api.sparrowsms.com/v2/credit \
curl -s http://api.sparrowsms.com/v2/credit/ \
-F token='<token-provided>' \
```
Expand All @@ -15,7 +15,7 @@

```
$api_url = "http://api.sparrowsms.com/v2/credit".
$api_url = "http://api.sparrowsms.com/v2/credit/?".
http_build_query(array(
'token' => '<token-provided>',
Expand All @@ -33,12 +33,45 @@
import requests

r = requests.get(
"http://api.sparrowsms.com/v2/credit",
"http://api.sparrowsms.com/v2/credit/",
params={'token' : '<token-provided>'})

status_code = r.status_code
response = r.text
response_json = r.json()


```

-------

## C\# (C-sharp)

```
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Text;
namespace SparrowSMSTest{
class Program{
static void Main(string[] args)
{
var getResponseTest = GetCredits('<token-provided>');
}
private static string GetCredits(string token)
{
using (var client = new WebClient())
{
string parameters = "?";
parameters += "token=" + token;
var responseString = client.DownloadString("http://api.sparrowsms.com/v2/credit/" + parameters);
return responseString;
}
}
}
```
80 changes: 75 additions & 5 deletions docs/examples_outgoing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```
curl -s http://api.sparrowsms.com/v2/sms \
curl -s http://api.sparrowsms.com/v2/sms/ \
-F token='<token-provided>' \
-F from='<Identity>' \
-F to='<comma_separated 10-digit mobile numbers>' \
Expand All @@ -20,7 +20,7 @@

```
$api_url = "http://api.sparrowsms.com/v2/sms?".
$api_url = "http://api.sparrowsms.com/v2/sms/?".
http_build_query(array(
'token' => '<token-provided>',
'from' => '<Identity>',
Expand All @@ -42,7 +42,7 @@
'to' => '<comma_separated 10-digit mobile numbers>',
'text' => 'SMS Message to be sent'));
$url = "http://api.sparrowsms.com/v2/sms";
$url = "http://api.sparrowsms.com/v2/sms/";
# Make the call using API.
$ch = curl_init();
Expand Down Expand Up @@ -70,7 +70,7 @@
import requests

r = requests.get(
"http://api.sparrowsms.com/v2/sms",
"http://api.sparrowsms.com/v2/sms/",
params={'token' : '<token-provided>',
'from' : '<Identity>',
'to' : '<comma_separated 10-digit mobile numbers>',
Expand All @@ -90,7 +90,7 @@
import requests

r = requests.post(
"http://api.sparrowsms.com/v2/sms",
"http://api.sparrowsms.com/v2/sms/",
data={'token' : '<token-provided>',
'from' : '<Identity>',
'to' : '<comma_separated 10-digit mobile numbers>',
Expand All @@ -100,4 +100,74 @@
response = r.text
response_json = r.json()

```

-------

## C\# (C-sharp)

**GET Method: **

```
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Text;
namespace SparrowSMSTest{
class Program{
static void Main(string[] args)
{
var getResponseTest = GetSendSMS('<Identity>', '<token-provided>', '<comma_separated 10-digit mobile numbers>', 'SMS Message to be sent');
}
private static string GetSendSMS(string from, string token, string to, string text)
{
using (var client = new WebClient())
{
string parameters = "?";
parameters += "from=" + from;
parameters += "&to=" + to;
parameters += "&text=" + text;
parameters += "&token=" + token;
var responseString = client.DownloadString("http://api.sparrowsms.com/v2/sms/" + parameters);
return responseString;
}
}
}
```


**POST Method: **

```
using System.Collections.Specialized;
using System.Net;
using System.Text;
namespace SparrowSMSTest{
class Program{
static void Main(string[] args){
var responseTest = PostSendSMS('<Identity>', '<token-provided>', '<comma_separated 10-digit mobile numbers>', 'SMS Message to be sent');
}
private static string PostSendSMS(string from, string token, string to, string text){
using (var client = new WebClient()){
var values = new NameValueCollection();
values["from"] = from;
values["token"] = token;
values["to"] = to;
values["text"] = text;
var response = client.UploadValues("http://api.sparrowsms.com/v2/sms/", "Post", values);
var responseString = Encoding.Default.GetString(response);
return responseString;
}
}
}
}
```
2 changes: 1 addition & 1 deletion docs/outgoing_credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It can be used to know about the available credits, consumed credits.
## Method
```
/credit
/credit/
```
## Parameters
Expand Down
2 changes: 1 addition & 1 deletion docs/outgoing_sendsms.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## Method
```
/sms
/sms/
```
## Parameters
Expand Down

0 comments on commit c377e69

Please sign in to comment.