Example #1
0
<?php

// Include libraries
include 'txty.api.php';
// Start Txty object
$txty = new Txty('mike', 'WPBFMD3PM5DVHSPDTP4B2DDQRU26NLFGHHVB4NQDATGRZVUG8EHZ74XP');
// If post
if ($_POST) {
    if (ctype_digit($_POST['dialcode']) && ctype_digit($_POST['number']) && $_POST['name'] && is_array($_POST['groups'])) {
        $contact = $txty->createContact($_POST['name'], $_POST['dialcode'] . $_POST['number'], $_POST['groups']);
        if ($contact) {
            $alert = '<div class="alert alert-success" role="alert">Awesome! Everything went well, and you are now a subsriber, welcome on the team! :-)</div>';
        } else {
            $alert = '<div class="alert alert-danger" role="alert">Damn! Something went wrong in some weird way, can you contact us? Awesome, talk to you soon!</div>';
        }
    }
}
// Dialcodes
$dialcodes = $txty->getDialcodes();
if ($dialcodes) {
    foreach ($dialcodes as $value) {
        $dialcodesHTML .= '<option value="' . $value['dialcode'] . '" iso="' . strtolower($value['cciso']) . '"' . (!$contact && $_POST['dialcode'] == $value['dialcode'] ? ' SELECTED' : false) . '>' . $value['country'] . '</option>';
    }
}
// Groups
$groups = $txty->viewGroups();
if ($groups['groups']) {
    foreach ($groups['groups'] as $value) {
        $groupsHTML .= '<label class="btn btn-primary"><input type="checkbox" name="groups[]" value="' . $value['controlgroup'] . '">&nbsp;' . $value['name'] . '</label>';
    }
}
Example #2
0
 public function __construct($user, $key)
 {
     self::$user = $user;
     self::$key = $key;
 }