本文整理匯總了PHP中Token::encode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Token::encode方法的具體用法?PHP Token::encode怎麽用?PHP Token::encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Token
的用法示例。
在下文中一共展示了Token::encode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: json
public function json($data = "")
{
Token::key();
header("Content-Type: application/json; charset=utf-8");
$this->result = new Result($data, Token::encode());
echo json_encode($this->result);
}
示例2: testDecodeExpired
/**
* @covers Token::decode
*/
public function testDecodeExpired()
{
//set timestamp for checking expiration
$token = new Token();
$token->payload = new stdClass();
$token->encode(0);
sleep(1);
//simulate receiving of a token value to decode
$this->object->value = $token->value;
$this->assertFalse($this->object->decode(), 'Token should not be decoded if expired');
}
示例3: generateToken
/**
* Generate a token for API usage.
*
* @return string Token generated
*/
public function generateToken($payload)
{
require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Token.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Configuration.php';
$configuration = new Configuration();
$token = new Token($configuration->get('hashKey'));
$token->payload = $payload;
$token->encode();
$result = new stdClass();
$result->token = $token->value;
//return the token
return $result;
}