Skip to content
enygma edited this page Feb 9, 2013 · 7 revisions

A Phone type of Devices represents a phone/smartphone device attached to the account.

Properties:

  • activated (boolean)
  • extension
  • name (user provided)
  • number
  • phone_id (internal ID)
  • platform (ex. "Google Android")
  • postdelay
  • predelay
  • sms_passcodes_sent
  • type (ex. "Mobile")

Methods:

As with User you can use the find and findAll to get device details:

<?php
$phone = new \DuoAuth\Devices\Phone();
$phones = $phone->findAll();
// or just one
$phoneDetail = $phone->find($phoneId);
?>

You can use a Phone object to associate it with a user account:

<?php
$phoneId = 'internal-phone-id';
$phone = new \DuoAuth\Device\Phone();
$phone->findById('phone-internal-id');
$user = new \DuoAuth\User();
$user->findByUsername('ccornutt');
$phone->associate($user, $phoneId);
?>

Alternatively, you can use a User object to attach a device:

<?php
$user = new \DuoAuth\User();
$phone = new \DuoAuth\Device\Phone();
$user->findByUsername('ccornutt');
$user->associateDevice($phone);
?>

You can create and update a Phone with the save method:

<?php
$phone = new \DuoAuth\Devices\Phone();
$phone->number = '2145551234';
$phone->save();

$phone->findById('existing-phone-id');
$phone->number = '1234567890';
$phone->save();
?>

And delete the Phone:

<?php
$phone = new \DuoAuth\Devices\Phone();
$phone->findById('existing-phone-id');
$phone->delete();
?>

You can also send two kinds of SMS messages to the Phone - activation and passcodes:

<?php
$phone = new \DuoAuth\Devices\Phone();
$phone->findById('existing-phone-id');

// resend SMS activation message
$phone->smsActivation();

// send passcodes to device
$phone->smsPasscode();
?>
Clone this wiki locally