Example code for SMS integration in language Python

Send SMS - REST API - JSON

            
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)

url = "https://api.labsmobile.com/json/send"

payload = "{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}"
headers = {
    'Content-Type': "application/json",
    'Authorization': "Basic %s" % b64Val,
    'Cache-Control': "no-cache"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

Credit inquiry - REST API - JSON

            
import requests, base64
usrPass = "myusername:mypassword"
b64Val = base64.b64encode(usrPass)

url = "https://api.labsmobile.com/json/balance"

headers = {
    'Authorization': "Basic %s" % b64Val,
    'Cache-Control': "no-cache"
    }

response = requests.request("GET", url, headers=headers)

print(response.text)

Send SMS - HTTP/GET

                
Python 2.x:

import urllib2
print urllib2.urlopen("http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message").read()

---------

Python 3.x:

import urllib.request
print urllib.request.urlopen("http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message").read()

---------

import requests
r = requests.get("http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message")

Credit inquiry - HTTP/GET

                
Python 2.x:

import urllib2
print urllib2.urlopen("http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]").read()

---------

Python 3.x:

import urllib.request
print urllib.request.urlopen("http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]").read()

---------

import requests
r = requests.get("http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]")
  • contact form support

    Sign up!

    Create a user account and send your SMS messages in seconds. You will have all the functionalities and benefits in the same platform.

    Send from API and manage your account with our online application WebSMS.

    Create new account
  • Artichoke Dolls, Artisanal eCommerce recommends LabsMobile

    Communication with eCommerce clients: change in status and delivery of orders with parcel tracking.

    Watch more reviews
  • dashboard aplicación online

    Maximum reliability at the best price

    At LabsMobile we only offer direct routes of maximum reliability and quality. Enjoy our platform and all our services for the price of an SMS.

    Pay ONLY for sent messages.

    Check our rates
  • dashboard aplicación online

    Need more info? Contact us!

    Our technical department has professionals with years of experience and we have made multiple integrations.

    We guide and help you through the process.

    Request technical support
  • Buy credits or set up automatic top-ups

    This tutorial explains how to reload credits step by step in your WebSMS account and also how to configure automatic reloads so that your account never runs out of credits.

    Ir al tutorial
loader