Welcome to TextMarks Lite - free ad-supported text messaging platform. Visit our main site for ad-free service. Free trial available!

Mobilize your world
Home
Tour
Buzz
Developers Center
Help
PHP

PHP API Client

TextMarks provides a PHP library to integrate with the XML-RPC HTTP API. This allows your apps to easily make calls into the TextMarks API. There are also other easier (less technical) ways to send and receive text messages from and to your apps without using this API.

 

Client Library

View | Download (TextMarksAPIClient.class.php - ~12 KB)

 

Example Code - Subscribe a user to a TextMark

<?php
require "TextMarksAPIClient.class.php";

// Try to subscribe a user to a TextMark:
$sMyApiKey        'MyAPIKEY_12345678';
$sMyTextMarksUser 'mytmuser'// (or my TextMarks phone#)
$sMyTextMarksPass 'mytmp@$$word';
$sKeyword         'MYKEYWORD';
$sPhone           '4155551212';
$tmapi = new TextMarksAPIClient_Messaging$sMyApiKey,
                                           
$sMyTextMarksUser,
                                           
$sMyTextMarksPass );
$tmapi->subscribe($sKeyword$sPhone);
?>
 

Example Code - Broadcast an alert to all users subscribed to a TextMark

<?php
require "TextMarksAPIClient.class.php";

// Broadcast an alert to all users subscribed to a TextMark:
$sMyApiKey        'MyAPIKEY_12345678';
$sMyTextMarksUser 'mytmuser'// (or my TextMarks phone#)
$sMyTextMarksPass 'mytmp@$$word';
$sKeyword         'MYKEYWORD';
$sMessage         "Team Picnic tomorrow 11am @ Brassley Park. ".
                    
"Look 4 orange flags. Spouses & kids welcome!";
$tmapi = new TextMarksAPIClient_Messaging$sMyApiKey,
                                           
$sMyTextMarksUser,
                                           
$sMyTextMarksPass );
$tmapi->postAlert($sKeyword$sMessage);
?>
 

Example Code - Send a text message to a single TextMark subscriber:

<?php
require "TextMarksAPIClient.class.php";

// Send a text message to a single TextMark subscriber:
$sMyApiKey        'MyAPIKEY_12345678';
$sMyTextMarksUser 'mytmuser'// (or my TextMarks phone#)
$sMyTextMarksPass 'mytmp@$$word';
$sKeyword         'MYKEYWORD';
$sTo              '415-555-1212';
$sMessage         "Order #1340 is clean & ready for pickup! ".
                    
"--EnviroClean 800-555-1212";
$tmapi = new TextMarksAPIClient_Messaging$sMyApiKey,
                                           
$sMyTextMarksUser,
                                           
$sMyTextMarksPass );
$tmapi->sendText($sKeyword$sTo$sMessage);
?>
 

More Sample Code

Looking for more sample code? Check out the STATEINFO sample code, which shows how to build a simple server-side script to dynamically respond to users SMS requests.

This STATEINFO script doesn't use the XML-RPC API at all. But if you wanted to build a mini-game where each state had a "captain" who was alerted by SMS every time somebody queried their state, then you could easily add that in using the API.

 
Service available on the following wireless networks: AT&T, Verizon Wireless, Sprint, T-Mobile, Virgin, Cricket, Alltel.
v2.69a-BETA  -  Copyright © 2008 TextMarks Inc. All rights reserved.