Example #1
0
 /**
  * usage: 
  *			$apiObj = TokBoxUser::createUser($jabberId, $accessSecret); 
  *			$profile_array = get_tokbox_user_profile($apiObj,$requested_id);
  *
  * @author sumotoy@*****.com
  */
 public static function getUserProfile(TokBoxApi $userObj, $target_jabberId)
 {
     $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
     $valid = $apiObj->validateAccessToken($userObj->getSecret(), $userObj->getJabberId());
     if (!$valid) {
         throw new Exception("Unable to connect to " . API_Config::API_SERVER . ". Please check to make sure API calls are executing properly");
     }
     $validXml = simplexml_load_string($valid, 'SimpleXMLElement', LIBXML_NOCDATA);
     if ($validXml->validateAccessToken->isValid == 'false') {
         throw new Exception("The Jabber ID and Access Secret combination you passed in are not valid");
     }
     $profile = $userObj->getUserProfile($target_jabberId);
     if (!$profile) {
         throw new Exception("Unable to connect to " . API_Config::API_SERVER . ". Please check to make sure API calls are executing properly");
     }
     $profileXml = simplexml_load_string($profile, 'SimpleXMLElement', LIBXML_NOCDATA);
     if (isset($profileXml->error)) {
         throw new Exception($profileXml->error, (int) $profileXml->error['code']);
     }
     $profileResults = array();
     $profileResults['userid'] = (string) $profileXml->user->userid;
     $profileResults['jabberid'] = (string) $profileXml->user->jabberid;
     $profileResults['firstname'] = (string) $profileXml->user->firstname;
     $profileResults['lastname'] = (string) $profileXml->user->lastname;
     $profileResults['displayName'] = (string) $profileXml->user->displayName;
     $profileResults['username'] = (string) $profileXml->user->username;
     $profileResults['isOnline'] = (string) $profileXml->user->isOnline;
     $profileResults['show'] = (string) $profileXml->user->show;
     return $profileResults;
 }
Example #2
0
 public static function generateInvite(TokBoxApi $callApiObj, $callId, $calleeJid)
 {
     $isValid = $callApiObj->validateAccessToken($callApiObj->getSecret(), $callApiObj->getJabberId());
     if (!$isValid) {
         throw new Exception("Unable to connect to " . API_Config::API_SERVER . ". Please check to make sure API calls are executing properly");
     }
     $isValidXml = simplexml_load_string($isValid, 'SimpleXMLElement', LIBXML_NOCDATA);
     if ($isValidXml->validateAccessToken->isValid == 'false') {
         throw new NotLoggedInException("The user is not properly validated");
     }
     $createInvite = $callApiObj->createInvite($callId, $calleeJid, $callApiObj->getJabberId());
     if (!$createInvite) {
         throw new Exception("Unable to connect to " . API_Config::API_SERVER . ". Please check to make sure API calls are executing properly");
     }
     $createInviteXml = simplexml_load_string($createInvite, 'SimpleXMLElement', LIBXML_NOCDATA);
     return $createInviteXml->createInvite->inviteId;
 }
 public static function addFriends(TokBoxApi $userObj, $contacts)
 {
     $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
     $valid = $apiObj->validateAccessToken($userObj->getSecret(), $userObj->getJabberId());
     if (!$valid) {
         throw new Exception("Unable to connect to " . API_Config::API_SERVER . ". Please check to make sure API calls are executing properly");
     }
     $validXml = simplexml_load_string($valid, 'SimpleXMLElement', LIBXML_NOCDATA);
     if ($validXml->validateAccessToken->isValid == 'false') {
         throw new Exception("The Jabber ID and Access Secret combination you passed in are not valid");
     }
     $addContact = $userObj->addContact($contacts, $userObjObj->getJabberId());
     if (!$addContact) {
         throw new Exception("Unable to connect to " . API_Config::API_SERVER . ". Please check to make sure API calls are executing properly");
     }
     $addContactXml = simplexml_load_string($addContact, 'SimpleXMLElement', LIBXML_NOCDATA);
     $addContactResults = array();
     foreach ($addContactXml->addContact->batchAddResult->contactResult as $result) {
         $addContactResults[$result['jabberId']] = $result['result'];
     }
     return $addContactResults;
 }
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->getFeedUnreadCount($apiObj->getJabberId());
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->postPublicVMail(Test_Config::TEST_VMAIL_TEXT, $apiObj->getJabberId(), Test_Config::TEST_VMAIL_SCOPE, Test_Config::TEST_VMAIL_VMAILID);
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->removeContact(Test_Config::TEST_ADD_CONTACT, $apiObj->getJabberId());
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
<?php

if ($_POST['submit']) {
    require_once '../SDK/TokBoxApi.php';
    require_once '../Test_Config.php';
    try {
        $startDate = trim($_POST['startDate']);
        $endDate = trim($_POST['endDate']);
        $daterange = "{$startDate} - {$endDate}";
        $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
        $apiObj->setJabberId(Test_Config::TEST_JABBERID);
        $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
        $result = $apiObj->getFeed($apiObj->getJabberId(), "all", 0, 10, "dt", $daterange);
        header("content-type: text/xml");
        echo $result;
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
Example #8
0
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->sendVMail($apiObj->getJabberId(), Test_Config::TEST_VMAIL_VMAILID, Test_Config::TEST_VMAIL_TOJABBERID);
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
Example #9
0
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->getFeed($apiObj->getJabberId());
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
Example #10
0
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->createCall('A Name', $apiObj->getJabberId(), "", "false");
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
Example #11
0
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->addComment(Test_Config::TEST_COMMENT_TEXT, Test_Config::TEST_COMMENTS_MESSAGEID, $apiObj->getJabberId());
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->forwardVMailToAllFriends($apiObj->getJabberId(), Test_Config::TEST_VMAIL_VMAILID);
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->forwardVmail($apiObj->getJabberId(), Test_Config::TEST_VMAIL_VMAILID, Test_Config::TEST_VMAIL_TOJABBERID);
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
Example #14
0
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->isFriend(Test_Config::TEST_ADD_CONTACT, $apiObj->getJabberId());
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}
<?php

require_once '../SDK/TokBoxApi.php';
require_once '../Test_Config.php';
try {
    $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
    $apiObj->setJabberId(Test_Config::TEST_JABBERID);
    $apiObj->setSecret(Test_Config::TEST_ACCESS_SECRET);
    $result = $apiObj->getUserProfile($apiObj->getJabberId());
    header("content-type: text/xml");
    echo $result;
} catch (Exception $e) {
    echo $e->getMessage();
}