本文整理汇总了PHP中URLBuilder::buildAssociate方法的典型用法代码示例。如果您正苦于以下问题:PHP URLBuilder::buildAssociate方法的具体用法?PHP URLBuilder::buildAssociate怎么用?PHP URLBuilder::buildAssociate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URLBuilder
的用法示例。
在下文中一共展示了URLBuilder::buildAssociate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: associate
public static function associate($server)
{
$data = URLBuilder::buildAssociate($server);
try {
$res = Poster::post($server, $data);
} catch (Exception $ex) {
return;
}
$data = array();
foreach (explode("\n", $res) as $line) {
if (preg_match('/^(.*?):(.*)$/', $line, $m)) {
$data[$m[1]] = $m[2];
}
}
$data['expires_at'] = time() + $data['expires_in'];
self::$data[$server][$data['assoc_handle']] = $data;
self::saveData();
}
示例2: associate
/**
* Attempts to associate with the specified server.
*
* @param String $server The server to associate with
*/
public static function associate($server, $assocType = null, $sessionType = null)
{
Logger::log('Attempting to associate with %s, assocType: %s, sessionType: %s', $server, $assocType, $sessionType);
$data = URLBuilder::buildAssociate($server, $_SESSION['openid']['version'], $assocType, $sessionType);
try {
$res = Poster::post($server, $data);
} catch (Exception $ex) {
Logger::log('Exception while posting: %s', $ex->getMessage());
return;
}
$data = array();
foreach (explode("\n", $res) as $line) {
if (preg_match('/^(.*?):(.*)$/', $line, $m)) {
$data[$m[1]] = $m[2];
}
}
if (isset($data['error_code']) && $data['error_code'] == 'unsupported-type') {
$cont = false;
if (isset($data['session_type']) && $data['session_type'] != $sessionType) {
// TODO: Check we support it before actually trying
$sessionType = $data['session_type'];
$cont = true;
}
if (isset($data['assoc_type']) && $data['assoc_type'] != $assocType) {
$assocType = $data['assoc_type'];
$cont = true;
}
if ($cont) {
self::associate($server, $assocType, $sessionType);
}
return;
}
try {
$data = self::decodeKey($server, $data);
} catch (Exception $ex) {
return;
}
$data['expires_at'] = time() + $data['expires_in'];
self::$data[$server][$data['assoc_handle']] = $data;
self::saveData();
}