本文整理汇总了PHP中Auth_OpenID_KVForm::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth_OpenID_KVForm::toArray方法的具体用法?PHP Auth_OpenID_KVForm::toArray怎么用?PHP Auth_OpenID_KVForm::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth_OpenID_KVForm
的用法示例。
在下文中一共展示了Auth_OpenID_KVForm::toArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _runTest
function _runTest()
{
// Do one parse, after which arrayToKV and kvToArray should be
// inverses.
$parsed1 = Auth_OpenID_KVForm::toArray($this->str);
$serial1 = Auth_OpenID_KVForm::fromArray($this->arr);
if ($this->lossy == "neither" || $this->lossy == "str") {
$this->assertEquals($this->arr, $parsed1, "str was lossy");
}
if ($this->lossy == "neither" || $this->lossy == "arr") {
$this->assertEquals($this->str, $serial1, "array was lossy");
}
$parsed2 = Auth_OpenID_KVForm::toArray($serial1);
$serial2 = Auth_OpenID_KVForm::fromArray($parsed1);
// Round-trip both
$parsed3 = Auth_OpenID_KVForm::toArray($serial2);
$serial3 = Auth_OpenID_KVForm::fromArray($parsed2);
$this->assertEquals($serial2, $serial3, "serialized forms differ");
// Check to make sure that they're inverses.
$this->assertEquals($parsed2, $parsed3, "parsed forms differ");
}
示例2: deserialize
/**
* Parse an association as stored by serialize(). This is the
* inverse of serialize.
*
* @param string $assoc_s Association as serialized by serialize()
* @return Auth_OpenID_Association $result instance of this class
*/
function deserialize($class_name, $assoc_s)
{
$pairs = Auth_OpenID_KVForm::toArray($assoc_s, $strict = true);
$keys = array();
$values = array();
foreach ($pairs as $key => $value) {
if (is_array($value)) {
list($key, $value) = $value;
}
$keys[] = $key;
$values[] = $value;
}
$class_vars = get_class_vars($class_name);
$class_assoc_keys = $class_vars['assoc_keys'];
sort($keys);
sort($class_assoc_keys);
if ($keys != $class_assoc_keys) {
trigger_error('Unexpected key values: ' . var_export($keys, true), E_USER_WARNING);
return null;
}
$version = $pairs['version'];
$handle = $pairs['handle'];
$secret = $pairs['secret'];
$issued = $pairs['issued'];
$lifetime = $pairs['lifetime'];
$assoc_type = $pairs['assoc_type'];
if ($version != '2') {
trigger_error('Unknown version: ' . $version, E_USER_WARNING);
return null;
}
$issued = intval($issued);
$lifetime = intval($lifetime);
$secret = base64_decode($secret);
return new $class_name($handle, $secret, $issued, $lifetime, $assoc_type);
}
示例3: fromKVForm
function fromKVForm($kvform_string)
{
// Create a Message from a KVForm string
return Auth_OpenID_Message::fromOpenIDArgs(Auth_OpenID_KVForm::toArray($kvform_string));
}
示例4: _makeKVPost
/**
* @access private
*/
function _makeKVPost($args, $server_url)
{
$mode = $args['openid.mode'];
$pairs = array();
foreach ($args as $k => $v) {
$v = urlencode($v);
$pairs[] = "{$k}={$v}";
}
$body = implode("&", $pairs);
$resp = $this->fetcher->post($server_url, $body);
if ($resp === null) {
return null;
}
$response = Auth_OpenID_KVForm::toArray($resp->body);
if ($resp->status == 400) {
return null;
} else {
if ($resp->status != 200) {
return null;
}
}
return $response;
}