Exemplo n.º 1
0
<?php

set_include_path(dirname(dirname(__FILE__)) . '/php/lib');
require_once 'SC/TcpClient/Exception.php';
require_once 'SC/TcpClient.php';
require_once 'SC/Pushup/Exception.php';
require_once 'SC/Pushup/Interface.php';
require_once 'SC/Pushup.php';
try {
    // get tcp client
    $tcpClient = new SC_TcpClient('127.0.0.1', 6666);
    // set connect timeout
    $tcpClient->setTimeout(1 * 1000);
    // connect to server
    $tcpClient->connect();
    // set read timeout
    $tcpClient->setTimeout(1 * 1000);
    // get pushup
    $pushup = new SC_Pushup();
    // inject tcp client
    $pushup->setTcpClient($tcpClient);
    // set pushup backend password
    $pushup->setBackendPassword('secret');
    // create a pushup entry for user 1 with session id "lociii"
    if ($pushup->createUser(1, 'lociii')) {
        echo 'success';
    }
} catch (Exception $e) {
    echo get_class($e) . ' (' . $e->getMessage() . ")\n";
}