本文整理汇总了PHP中OAuthRequestLogger::logging方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthRequestLogger::logging方法的具体用法?PHP OAuthRequestLogger::logging怎么用?PHP OAuthRequestLogger::logging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuthRequestLogger
的用法示例。
在下文中一共展示了OAuthRequestLogger::logging方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flush
/**
* Logs the request to the database, sends any cached output.
* Also called on shutdown, to make sure we always log the request being handled.
*/
static function flush()
{
if (OAuthRequestLogger::$logging) {
OAuthRequestLogger::$logging = false;
if (is_null(OAuthRequestLogger::$sent)) {
// What has been sent to the user-agent?
$data = ob_get_contents();
if (strlen($data) > 0) {
ob_end_flush();
} elseif (ob_get_level()) {
ob_end_clean();
}
$hs = headers_list();
$sent = implode("\n", $hs) . "\n\n" . $data;
} else {
// The request we sent
$sent = OAuthRequestLogger::$sent;
}
if (is_null(OAuthRequestLogger::$received)) {
// Build the request we received
$hs0 = self::getAllHeaders();
$hs = array();
foreach ($hs0 as $h => $v) {
$hs[] = "{$h}: {$v}";
}
$data = '';
$fh = @fopen('php://input', 'r');
if ($fh) {
while (!feof($fh)) {
$s = fread($fh, 1024);
if (is_string($s)) {
$data .= $s;
}
}
fclose($fh);
}
$received = implode("\n", $hs) . "\n\n" . $data;
} else {
// The answer we received
$received = OAuthRequestLogger::$received;
}
// The request base string
if (OAuthRequestLogger::$request_object) {
$base_string = OAuthRequestLogger::$request_object->signatureBaseString();
} else {
$base_string = '';
}
// Figure out to what keys we want to log this request
$keys = array();
if (OAuthRequestLogger::$request_object) {
$consumer_key = OAuthRequestLogger::$request_object->getParam('oauth_consumer_key', true);
$token = OAuthRequestLogger::$request_object->getParam('oauth_token', true);
switch (get_class(OAuthRequestLogger::$request_object)) {
// tokens are access/request tokens by a consumer
case 'OAuthServer':
case 'OAuthRequestVerifier':
$keys['ocr_consumer_key'] = $consumer_key;
$keys['oct_token'] = $token;
break;
// tokens are access/request tokens to a server
// tokens are access/request tokens to a server
case 'OAuthRequester':
case 'OAuthRequestSigner':
$keys['osr_consumer_key'] = $consumer_key;
$keys['ost_token'] = $token;
break;
}
}
// Log the request
if (OAuthRequestLogger::$store_log) {
$store = OAuthStore::instance();
$store->addLog($keys, $received, $sent, $base_string, OAuthRequestLogger::$note, OAuthRequestLogger::$user_id);
}
OAuthRequestLogger::$log[] = array('keys' => $keys, 'received' => $received, 'sent' => $sent, 'base_string' => $base_string, 'note' => OAuthRequestLogger::$note);
}
}