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

API V2 PHP Client

TextMarks provides a PHP library to integrate with the V2 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 (TextMarksV2APIClient.php - ~10 KB)

Support Files (required ONLY for PHP 5.1 or older)

Download (JSON.php - ~34 KB)

 

Example Code - Invite a user to join a TextMark group

<?php
require "TextMarksV2APIClient.php";

// Invite a user to join a TextMark group:
$sMyApiKey        'MyAPIKEY_12345678';
$sKeyword         'MYKEYWORD';
$sPhone           '4155551212';
$tmapi = new TextMarksV2APIClient($sMyApiKey);
$tmapi->call('Anybody''invite_to_group', array(
    
'tm' => $sKeyword,
    
'user' => $sPhone
    
));
?>
 

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

<?php
require "TextMarksV2APIClient.php";

// Broadcast a message to a TextMark group:
$sMyApiKey        'MyAPIKEY_12345678';
$sMyTextMarksUser 'mytmuser'// (or my TextMarks phone#)
$sMyTextMarksPass 'mytmp@$$word';
$sKeyword         'MYKEYWORD';
$sMessage         "This is an alert sent from the PHP API Client. Did it work?";
$tmapi = new TextMarksV2APIClient($sMyApiKey$sMyTextMarksUser$sMyTextMarksPass);
$tmapi->call('GroupLeader''broadcast_message', array(
    
'tm' => $sKeyword,
    
'msg' => $sMessage
    
));
?>
 

Example Code - Check a keyword's status/availability:

<?php
require "TextMarksV2APIClient.php";

// Check a keyword status/availability:
$sMyApiKey        'MyAPIKEY_12345678';
$sKeyword         'MYKEYWORD';
$tmapi = new TextMarksV2APIClient($sMyApiKey);
$resp $tmapi->call('Anybody''keyword_status', array(
    
'keyword' => $sKeyword
    
));
echo 
"*Keyword status code: " $resp['body']['status'] . "\n";
?>

Example Code Output:

*Response:
Array
(
    [head] => Array
        (
            [rescode] => 0
            [resmsg] => OK
            [version] => 2.57a-BETA
        )

    [body] => Array
        (
            [available] => 1
            [status] => available
            [keyword] => MYKEYWORD
        )

)
*Keyword status code: available
				
 

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 V2 HTTP API at all. But if you wanted to extend STATEINFO into 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.68e-BETA  -  Copyright © 2008 TextMarks Inc. All rights reserved.