---
title: HTTP API Sample Code 
description: SMS Global Knowledgebase
---

[![](https://cdn.craft.cloud/ff00d28e-6061-427e-b58d-8267ebeaad6b/builds/a173c27c-7ed2-40a3-b553-3262aea64d9e/artifacts/dist/img/logo/sms-global-logo.svg)](https://smsglobal.com?hsLang=en-au)

 smsglobal.com [Talk to an expert](https://www.smsglobal.com/contact?hsLang=en-au)  Talk to an expert

[Skip to content](https://knowledgebase.smsglobal.com/http-api-sample-code-smsglobal-help-center#main-content)

[![SMSGLOBAL LOGO WHITE-2](https://knowledgebase.smsglobal.com/hs-fs/hubfs/SMSGLOBAL%20LOGO%20WHITE-2.png?width=500&height=100&name=SMSGLOBAL%20LOGO%20WHITE-2.png)](https://www.smsglobal.com/?hsLang=en-au)

Open main navigation

Close main navigation

- [Contact us](https://www.smsglobal.com/contact/)

[Contact us](https://www.smsglobal.com/contact/?hsLang=en-au)

 Advice and answers from the SMSGlobal Team

- There are no suggestions because the search field is empty.

1. [SMS Global Knowledgebase](https://knowledgebase.smsglobal.com/?hsLang=en-au)
2. [API and Integration](https://knowledgebase.smsglobal.com/api-and-integration?hsLang=en-au)

# HTTP API Sample Code 

## Sample code for using HTTP API in various programming languages

Below is some sample code in various programming languages using HTTP API.

---

### C#

```
private string SMSGlobalData(string username, string password, string source, string destination, string text){      System.Text.StringBuilder postData = new System.Text.StringBuilder("action=sendsms");      postData.Append("&user=");      postData.Append(System.Web.HttpUtility.UrlEncode(username));      postData.Append("&password=");      postData.Append(System.Web.HttpUtility.UrlEncode(password));      postData.Append("&from=");      postData.Append(System.Web.HttpUtility.UrlEncode(source));      postData.Append("&to=");      postData.Append(System.Web.HttpUtility.UrlEncode(destination));      postData.Append("&text=");      postData.Append(System.Web.HttpUtility.UrlEncode(text));      return postData.ToString();}private string SendSms(string url, string postData){      System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();      byte[] data = encoding.GetBytes(postData);      HttpWebRequest smsRequest = System.Net.WebRequest.Create(url);      smsRequest.Method = "POST";      smsRequest.ContentType = "application/x-www-form-urlencoded";      smsRequest.ContentLength = data.Length;      System.IO.Stream smsDataStream = null;      smsDataStream = smsRequest.GetRequestStream();      smsDataStream.Write(data, 0, data.Length);      smsDataStream.Close();      System.Net.WebResponse smsResponse = smsRequest.GetResponse();      byte[] responseBuffer = new byte[smsResponse.ContentLength];      smsResponse.GetResponseStream().Read(responseBuffer, 0, smsResponse.ContentLength - 1);      smsResponse.Close();      return encoding.GetString(responseBuffer);}
```

 

---

### PHP

```
<?php      $username = 'USERNAME';     $password = 'PASSWORD';     $destination = 'PHONE NUMBER';     $source = 'FROM NAME';     $text = 'SAMPLE TEXT';              $content =  'action=sendsms'.                 '&user='.rawurlencode($username).                 '&password='.rawurlencode($password).                 '&to='.rawurlencode($destination).                 '&from='.rawurlencode($source).                 '&text='.rawurlencode($text);          $smsglobal_response = file_get_contents('https://api.smsglobal.com/http-api.php?'.$content);          //Sample Response     //OK: 0; Sent queued message ID: 04b4a8d4a5a02176 SMSGlobalMsgID:6613115713715266           $explode_response = explode('SMSGlobalMsgID:', $smsglobal_response);          if(count($explode_response) == 2) { //Message Success         $smsglobal_message_id = $explode_response[1];                  //SMSGlobal Message ID         echo $smsglobal_message_id;     } else { //Message Failed         echo 'Message Failed'.'<br />';                  //SMSGlobal Response         echo $smsglobal_response;         } ?>
```

 

---

### cURL

```
$smsGlobalURL = 'https://api.smsglobal.com/http-api.php?';$query = http_build_query(['action' => 'sendsms','user' => 'USERNAME','password' => 'PASSWORD','from' => 'SENDER','to' => '614XXXXXXXXX','text' => 'TEXT MESSAGE HERE']);$smsGlobalURL = $smsGlobalURL.$query;// create a new curl resource and set options$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $smsGlobalURL);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$output = curl_exec($ch);curl_close($ch);
```

 

---

For any further API related assistance, don't hesitate to reach out to our Customer Support Team.

- [Sending a SMS](https://knowledgebase.smsglobal.com/sending-a-sms?hsLang=en-au)
- [Sender ID](https://knowledgebase.smsglobal.com/sender-id?hsLang=en-au)
- [API and Integration](https://knowledgebase.smsglobal.com/api-and-integration?hsLang=en-au)
- [Email to SMS](https://knowledgebase.smsglobal.com/email-to-sms?hsLang=en-au)
- [Reporting](https://knowledgebase.smsglobal.com/reporting?hsLang=en-au)
- [Sub-Accounts](https://knowledgebase.smsglobal.com/sub-accounts?hsLang=en-au)
- [Delivery Receipts](https://knowledgebase.smsglobal.com/delivery-receipts?hsLang=en-au)
- [Billing and Payments](https://knowledgebase.smsglobal.com/billing-and-payments?hsLang=en-au)
- [Contact Lists](https://knowledgebase.smsglobal.com/contact-lists?hsLang=en-au)
- [Managing Opt-Outs](https://knowledgebase.smsglobal.com/managing-opt-outs?hsLang=en-au)
- [Campaigns](https://knowledgebase.smsglobal.com/campaigns?hsLang=en-au)
- [Templates](https://knowledgebase.smsglobal.com/templates?hsLang=en-au)
- [MMS](https://knowledgebase.smsglobal.com/mms?hsLang=en-au)
- [Voice](https://knowledgebase.smsglobal.com/voice?hsLang=en-au)
- [Laws and Regulations](https://knowledgebase.smsglobal.com/laws-and-regulations?hsLang=en-au)
- [Video Tutorials](https://knowledgebase.smsglobal.com/video-tutorials?hsLang=en-au)
- [Account Settings](https://knowledgebase.smsglobal.com/account-settings?hsLang=en-au)
- [Understanding Unicode Messages](https://knowledgebase.smsglobal.com/understanding-unicode-messages?hsLang=en-au)

[![SMSGlobal](https://knowledgebase.smsglobal.com/hs-fs/hubfs/SMSGlobal-logo-black-transp.png?width=200&height=56&name=SMSGlobal-logo-black-transp.png "SMSGlobal")](http://smsglobal.com?hsLang=en-au)

[mailto:support@email.com](mailto:support@email.com)

Copyright © 2026, SMSGlobal

![](https://analytics.twitter.com/i/adsct?txn_id=nxnc4&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0) ![](https://t.co/i/adsct?txn_id=nxnc4&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0)

[![SMSGlobal](https://cdn.craft.cloud/ff00d28e-6061-427e-b58d-8267ebeaad6b/builds/a173c27c-7ed2-40a3-b553-3262aea64d9e/artifacts/dist/img/logo/sms-global-logo-light.svg)](https://smsglobal.com/?hsLang=en-au)

 © Copyright . SMSGlobal. All rights reserved.

[smsglobal.com](https://smsglobal.com/?hsLang=en-au) [Talk to an expert](https://smsglobal.com/contact/?hsLang=en-au)