/** * 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; }
public static function joinCall(TokBoxApi $callApiObj, $inviteId) { $joinCall = $callApiObj->joinCall($inviteId); if (!$joinCall) { throw new Exception("Unable to connect to " . API_Config::API_SERVER . ". Please check to make sure API calls are executing properly"); } $joinCallXml = simplexml_load_string($joinCall, 'SimpleXMLElement', LIBXML_NOCDATA); return $joinCallXml->joinCall->callId; }
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); $result = $apiObj->registerUser(Test_Config::getRegisterEmail(), Test_Config::getRegisterLastName(), Test_Config::getRegisterFirstName()); 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->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->createCall('A Name', $apiObj->getJabberId(), "", "false"); 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->getAllPostComments(Test_Config::TEST_COMMENTS_MESSAGEID); 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->getVMail(Test_Config::TEST_VMAIL_MESSAGEID); 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); $result = $apiObj->validateAccessToken(Test_Config::TEST_ACCESS_SECRET, Test_Config::TEST_JABBERID); 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(); } }
<?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->createInvite(Test_Config::TEST_CALLID, Test_Config::TEST_CALLEE_JABBERID, Test_Config::TEST_JABBERID); 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); $result = $apiObj->createGuestUser(API_Config::PARTNER_KEY); 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->joinCall(Test_Config::TEST_INVITEID); 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->updateToken($apiObj->getRequestToken(API_Config::CALLBACK_URL)); $apiObj->loginUser(); } catch (Exception $e) { echo $e->getMessage(); }
<?php if (isset($_POST['submit'])) { require_once '../SDK/TokBoxApi.php'; require_once '../Test_Config.php'; try { $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET); $result = $apiObj->registerUser($_POST['email'], $_POST['lastname'], $_POST['firstname']); $resultxml = simplexml_load_string($result); if ($resultxml->error) { echo "There was an error of type: " . $resultxml->error['type'] . " with message " . $resultxml->error; } else { echo "User " . $resultxml->registerUser->firstname . " " . $resultxml->registerUser->lastname . " was created with:<br/>"; echo " Jabber ID: " . $resultxml->registerUser->jabberId . "<br/>"; echo " Secret: " . $resultxml->registerUser->secret . "<br/>"; } } catch (Exception $e) { echo $e->getMessage(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Register User</title> </head> <body> <form name="registerForm" method="POST" action="registerForm.php"> <table> <tr>
<?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->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->deleteVmail(Test_Config::TEST_DELETE_VMAIL_TYPE, Test_Config::TEST_DELETE_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->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(); }
<?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 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(); }
<?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); $result = $apiObj->getRequestToken(API_Config::CALLBACK_URL); 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->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->markVmailRead(Test_Config::TEST_MARKREAD_MESSAGEID); header("content-type: text/xml"); echo $result; } catch (Exception $e) { echo $e->getMessage(); }