Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Documentation

Matthew Kilpatrick edited this page Mar 9, 2020 · 3 revisions

In order to use this library, you will need a ThingsMobile API token. This requires an account to use with the production API (and can be generated here), however there are credentials for the staging API provided - these are included in the examples folder of this library, and are used for any example code in the wiki.

Navigation


Authentication

In order to use the library, a client object is required to be created. The client class constructor takes 3 parameters: username, API token, and environment - this is only required if you wish to use the development environment.

<?php
$client = new \ThingsMobilePHP\Client(
  'TMTEST',
  '91c6ce3c-a848-4f0e-bfca-ab9eeff5d1e6',
  \ThingsMobilePHP\Client::ENVIRONMENT_DEVELOPMENT
);

SIM

Activate SIM (3.1)

Activates a specified sim. Requires MSISDN and ICCID to be set.

$sim = new \ThingsMobilePHP\Models\Sim();
$sim->setMsisdn('882360000000004')->setIccid('');
$client->sim()->activate($sim);

Block SIM (3.2)

Block a specified SIM. Requires either MSISDN or ICCID to be set on SIM object.

$sim = new \ThingsMobilePHP\Models\Sim();
$sim->setMsisdn('882360000000004');
$client->sim()->block($sim);

Unblock SIM (3.3)

Unblock a specified SIM. Requires either MSISDN or ICCID to be set on SIM object.

$sim = new \ThingsMobilePHP\Models\Sim();
$sim->setMsisdn('882360000000004');
$client->sim()->unblock($sim);

SIM status (3.4)

Get SIM status. Requires either MSISDN or ICCID to be set on SIM object. Returns a SIM model with all fields populated.

$sim = new \ThingsMobilePHP\Models\Sim();
$sim->setMsisdn('882360000000004');
$sim = $client->sim()->status($sim);
// eg. $sim->getBalance();

List SIMs (3.5)

List all sims in account. Allows optional searching by tag or name, which can be passed as an array - the first parameter accepted by the method.

$allSims = $client->sim()->list();
$specificSims = $client->sim()->list(['name' => 'test']);

Update SIM (3.8, 3.9, 3.10, 3.11)

Update any changed attributes on the provided SIM object. Requires either MSISDN or ICCID to be set on SIM object. The values which can be updated are:

  • name
  • tag
  • expirationDate
  • blockSim
  • dailyLimit
  • blockSimDaily
  • monthlyLimit
  • blockSimMonthly
  • totalLimit
  • blockSimTotal

This method combines multiple API endpoint calls to simplify usage.

$sim = new \ThingsMobilePHP\Models\Sim();
$sim->setMsisdn('882360000000004');
$sim->setName('new name')->setTag('tag')->setDailyLimit(100);
$client->sim()->update($sim);

SMS

Send SMS (3.16)

Send a SMS to a specified SIM. Message can be up to 160 characters.

$sim = new \ThingsMobilePHP\Models\Sim();
$sim->setMsisdn('882360000000004');
$client->sms()->send($sim, 'message to send here');