本文整理汇总了PHP中OAuth::get_variable方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuth::get_variable方法的具体用法?PHP OAuth::get_variable怎么用?PHP OAuth::get_variable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuth
的用法示例。
在下文中一共展示了OAuth::get_variable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stdClass
if ($u) {
$api_session->oauth_status = true;
$user->is_logged = true;
$user->id = $id;
$user->info = new stdClass();
$user->info->id = $id;
$user->info->is_network_admin = $u->is_network_admin;
$user->info->is_posts_protected = $u->is_posts_protected;
$user->info->username = $u->username;
$user->info->network_id = $u->network_id;
}
unset($id, $u);
//success
}
}
$api_session->oauth_error = $oauth_client->get_variable('error_msg');
} else {
$api_session->oauth_error = 'Missing OAuth parameters';
}
} elseif ($auth = check_if_basic_auth()) {
$this->db2->query('SELECT id FROM users WHERE (email="' . $this->db2->e($auth[0]) . '" OR username="' . $this->db2->e($auth[0]) . '") AND password="' . md5($auth[1]) . '" AND active=1 LIMIT 1');
if (!($obj = $this->db2->fetch_object())) {
$api_session->oauth_error = 'Invalid Authorization header.';
} else {
$u = $this->network->get_user_by_id($obj->id);
if ($u) {
$api_session->bauth_status = true;
$user->is_logged = true;
$user->id = $u->id;
$user->info = new stdClass();
$user->info->id = $u->id;
示例2: array
$api_session->available_resources = array('create', 'destroy', 'exists', 'show', 'verify_credentials', 'incoming', 'outgoing', 'rate_limit_status', 'update_profile_image', 'end_session', 'update_profile', 'update_profile_colors');
$api_session->oauth_error = '';
if (($auth = prepare_request()) || ($auth = prepare_header())) {
if (isset($auth['oauth_version']) && $auth['oauth_version'] != '1.0') {
$api_session->oauth_error = 'Not supported OAuth version';
} elseif (isset($auth['oauth_consumer_key'], $auth['oauth_nonce'], $auth['oauth_token'], $auth['oauth_signature_method'], $auth['oauth_signature'], $auth['oauth_timestamp'])) {
$oauth_client = new OAuth($auth['oauth_consumer_key'], $auth['oauth_nonce'], $auth['oauth_token'], $auth['oauth_timestamp'], $auth['oauth_signature']);
$oauth_client->set_variable('stage_url', $C->SITE_URL . '1/account/' . $api_session->resource . '.' . $api_session->format);
if (isset($auth['oauth_version'])) {
$oauth_client->set_variable('version', '1.0');
}
if ($oauth_client->is_valid_get_resource_request()) {
if ($auth['oauth_signature_method'] != 'HMAC-SHA1') {
$api_session->oauth_error = 'Unsupported signature method';
} elseif (!$oauth_client->decrypt_hmac_sha1()) {
$api_session->oauth_error = 'Invalid signature' . $oauth_client->get_variable('error_msg');
} else {
//success
$id = $oauth_client->get_user_id(urldecode($auth['oauth_token']));
$u = $this->network->get_user_by_id($id);
if ($u) {
$api_session->oauth_status = true;
$user->is_logged = true;
$user->id = $id;
$user->info = new stdClass();
$user->info->id = $id;
$user->info->is_network_admin = $u->is_network_admin;
$user->info->is_posts_protected = $u->is_posts_protected;
$user->info->username = $u->username;
$user->info->network_id = $u->network_id;
$user->info->avatar = $u->avatar;
示例3: elseif
$err = false;
$user_id = $user->id;
} elseif ($_POST['submit'] == 'Submit') {
$user->logout();
$user->login($_POST['email'], md5($_POST['password']));
if (!$user->is_logged) {
$err = true;
} else {
$user_id = $user->id;
$err = false;
}
}
if (!$err) {
$oauth_client->set_variable('user_id', $user_id);
if (!($verifier = $oauth_client->get_verifier_request())) {
echo $oauth_client->get_variable('error_msg');
} else {
if (!$oauth_client->update_field_in_table('oauth_request_token', 'user_id', $oauth_client->get_variable('user_id'), 'request_token', $_GET['oauth_token']) || !$oauth_client->update_field_in_table('oauth_request_token', 'time_stamp', time(), 'request_token', $_GET['oauth_token'])) {
echo $oauth_client->get_variable('error_msg');
} else {
$callback = $oauth_client->get_field_in_table('applications', 'callback_url', 'app_id', $oauth_client->get_value_in_consumer_key('app_id'));
$oauth_client->log();
if ($callback) {
$this->redirect($callback . '?oauth_token=' . $_GET['oauth_token'] . '&oauth_verifier=' . $verifier);
exit;
} else {
echo '<p style="width: auto; text-align: center;">Your verifier is: <b>' . $verifier . '</b>.You should enter it manually at your service provider.</p><div class="klear"></div>';
$snow_form = false;
}
}
}
示例4: elseif
if ($_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['REQUEST_METHOD'] != 'POST') {
echo 'Invalid request method.';
exit;
} elseif (isset($_REQUEST['oauth_version']) && $_REQUEST['oauth_version'] != '1.0') {
echo 'Invalid OAuth version.';
exit;
}
if (isset($_REQUEST['oauth_consumer_key'], $_REQUEST['oauth_nonce'], $_REQUEST['oauth_signature_method'], $_REQUEST['oauth_signature'], $_REQUEST['oauth_timestamp']) && $_REQUEST['oauth_signature_method'] != '') {
require_once $C->INCPATH . 'classes/class_oauth.php';
$oauth_client = new OAuth($_REQUEST['oauth_consumer_key'], $_REQUEST['oauth_nonce'], $_REQUEST['oauth_signature'], $_REQUEST['oauth_timestamp']);
if (isset($_REQUEST['oauth_version'])) {
$oauth_client->set_variable('version', '1.0');
}
if ($oauth_client->is_valid_consumer_key() && $oauth_client->is_valid_nonce() && $oauth_client->is_valid_timestamp() && strtolower(urldecode($_REQUEST['oauth_signature_method'])) == 'hmac-sha1' && $oauth_client->decrypt_hmac_sha1() && $oauth_client->is_valid_application()) {
$oauth_client->set_variable('token_secret', $oauth_client->generate_random_value());
$oauth_client->set_variable('request_token', $oauth_client->generate_request_token());
if ($oauth_client->set_request_table()) {
echo 'oauth_token_secret=' . $oauth_client->get_variable('token_secret');
echo '&oauth_token=' . $oauth_client->get_variable('request_token') . '&oauth_callback_confirmed=true';
} else {
echo $oauth_client->get_variable('error_msg');
exit;
}
} else {
echo $oauth_client->there_is_error() ? $oauth_client->get_variable('error_msg') : 'Invalid signature method';
exit;
}
} else {
echo 'Missing OAuth parameter(s).';
exit;
}
示例5: elseif
if ($_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['REQUEST_METHOD'] != 'POST') {
echo 'Invalid request method.';
exit;
} elseif (isset($_REQUEST['oauth_version']) && $_REQUEST['oauth_version'] != '1.0') {
echo 'Not supported oauth version.';
exit;
}
if (isset($_REQUEST['oauth_consumer_key'], $_REQUEST['oauth_nonce'], $_REQUEST['oauth_signature_method'], $_REQUEST['oauth_signature'], $_REQUEST['oauth_timestamp'], $_REQUEST['oauth_token'], $_REQUEST['oauth_verifier'])) {
require_once $C->INCPATH . 'classes/class_oauth.php';
$oauth_client = new OAuth($_REQUEST['oauth_consumer_key'], $_REQUEST['oauth_nonce'], $_REQUEST['oauth_signature'], $_REQUEST['oauth_timestamp'], $_REQUEST['oauth_token'], $_REQUEST['oauth_verifier']);
if (isset($_REQUEST['oauth_version'])) {
$oauth_client->set_variable('version', '1.0');
}
if ($oauth_client->is_valid_access_token_request() && strtolower(urldecode($_REQUEST['oauth_signature_method'])) == 'hmac-sha1' && $oauth_client->decrypt_hmac_sha1()) {
$oauth_client->set_variable('access_token', $oauth_client->generate_access_token());
$oauth_client->set_variable('user_id', $oauth_client->get_field_in_table('oauth_request_token', 'user_id', 'request_token', $_REQUEST['oauth_token']));
if ($oauth_client->set_access_table() && $oauth_client->delete_row_in_table('oauth_request_token', 'request_token', $oauth_client->get_variable('request_token'))) {
echo 'oauth_token_secret=' . urlencode($oauth_client->get_variable('token_secret'));
echo '&oauth_token=' . urlencode($oauth_client->get_variable('access_token'));
} else {
echo $oauth_client->get_variable('error_msg');
exit;
}
} else {
echo $oauth_client->there_is_error() ? $oauth_client->get_variable('error_msg') : 'Invalid signature method';
exit;
}
} else {
echo 'Missing OAuth parameters.';
exit;
}