public function __construct() { $this->platformSR = SocialRecordManager::importSocialRecord($this->platformSRjson); $this->platformSocialRecord = $this->platformSR['socialRecord']; $this->platformAccountKeyPair = $this->platformSR['accountKeyPair']; $this->platformPersonalKeyPair = $this->platformSR['personalKeyPair']; $this->aliceSR = SocialRecordManager::importSocialRecord($this->aliceSRjson); $this->aliceSocialRecord = $this->aliceSR['socialRecord']; $this->aliceAccountKeyPair = $this->aliceSR['accountKeyPair']; $this->alicePersonalKeyPair = $this->aliceSR['personalKeyPair']; $this->sonic = Sonic::initInstance(new EntityAuthData($this->platformSocialRecord, $this->platformAccountKeyPair, $this->platformPersonalKeyPair)); Sonic::setUserAuthData(new EntityAuthData($this->aliceSocialRecord, $this->aliceAccountKeyPair)); Sonic::setContext(Sonic::CONTEXT_USER); }
public function testSonic() { $platformSR = SocialRecordManager::importSocialRecord($this->platformSRjson); $platformSocialRecord = $platformSR['socialRecord']; $platformAccountKeyPair = $platformSR['accountKeyPair']; $platformPersonalKeyPair = $platformSR['personalKeyPair']; $aliceSR = SocialRecordManager::importSocialRecord($this->aliceSRjson); $aliceSocialRecord = $aliceSR['socialRecord']; $aliceAccountKeyPair = $aliceSR['accountKeyPair']; $alicePersonalKeyPair = $aliceSR['personalKeyPair']; $sonic = Sonic::initInstance(new EntityAuthData($platformSocialRecord, $platformAccountKeyPair, $platformPersonalKeyPair)); $this->assertEquals($platformSocialRecord->getGlobalID(), Sonic::getContextGlobalID()); Sonic::setUserAuthData(new EntityAuthData($aliceSocialRecord, $aliceAccountKeyPair)); Sonic::setContext(Sonic::CONTEXT_USER); $this->assertEquals($aliceSocialRecord->getGlobalID(), Sonic::getContextGlobalID()); }
<?php namespace sgoendoer\Sonic\examples; require_once __DIR__ . '/../vendor/autoload.php'; use sgoendoer\Sonic\Sonic; use sgoendoer\Sonic\Identity\EntityAuthData; use sgoendoer\Sonic\Identity\SocialRecordManager; try { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // importing SocialRecord objects to work with //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // load SocialRecords from files to instatiaze the Sonic framework $srp = SocialRecordManager::importSocialRecord(file_get_contents(__DIR__ . '/data/SRPlatform.json')); $platformSocialRecord = $srp['socialRecord']; $platformAccountKeyPair = $srp['accountKeyPair']; $platformPersonalKeyPair = $srp['personalKeyPair']; $sra = SocialRecordManager::importSocialRecord(file_get_contents(__DIR__ . '/data/SRAlice.json')); $userSocialRecord = $sra['socialRecord']; $userAccountKeyPair = $sra['accountKeyPair']; $userPersonalKeyPair = $sra['personalKeyPair']; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // initializing Sonic SDK //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // instantiaze the Sonic framework with the platform's SocialRecord $sonic = Sonic::initInstance(new EntityAuthData($platformSocialRecord, $platformAccountKeyPair, $platformPersonalKeyPair)); Sonic::setUserAuthData(new EntityAuthData($userSocialRecord, $userAccountKeyPair)); Sonic::setContext(Sonic::CONTEXT_USER); } catch (\Exception $e) { die($e->getMessage() . "\n\n" . $e->getTraceAsString()); }