本文整理汇总了PHP中parent::oauth_settings方法的典型用法代码示例。如果您正苦于以下问题:PHP parent::oauth_settings方法的具体用法?PHP parent::oauth_settings怎么用?PHP parent::oauth_settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parent
的用法示例。
在下文中一共展示了parent::oauth_settings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_access_tokens
public function get_access_tokens($scope = array())
{
if (!empty($_GET['oauth_verifier']) && !empty($_GET['oauth_token']) && isset($_SESSION['oauth_token_secret'])) {
parent::$oauth_settings['oauth_token_secret'] = $_SESSION['oauth_token_secret'];
unset($_SESSION['oauth_token_secret']);
$oauth_fields['oauth_verifier'] = $_GET['oauth_verifier'];
$oauth_fields['oauth_token'] = $_GET['oauth_token'];
$url = 'https://secure.' . self::$url_part . '.co.nz/Oauth/AccessToken';
$method = 'POST';
parent::build_request($url, $method, $oauth_fields);
$res = parent::do_request($url, $method);
parse_str($res[0], $res[0]);
if (!isset($res[0]['oauth_token']) || !isset($res[0]['oauth_token_secret'])) {
switch ($res[1]['http_code']) {
case self::TM_ERROR_REQUEST:
$this->last_error = self::TM_ERROR_REQUEST;
break;
case self::TM_ERROR_AUTHENTICATION:
$this->last_error = self::TM_ERROR_AUTHENTICATION;
break;
case self::TM_ERROR_RATE_LIMIT:
$this->last_error = self::TM_ERROR_RATE_LIMIT;
break;
case self::TM_ERROR_GENERIC:
$this->last_error = self::TM_ERROR_GENERIC;
break;
}
return $res;
}
parent::$oauth_settings = array_merge(parent::$oauth_settings, array('oauth_token' => $res[0]['oauth_token'], 'oauth_token_secret' => $res[0]['oauth_token_secret']));
return $res;
}
$scope_str = implode($scope, ',');
$oauth_fields = array('oauth_callback' => self::$callback_url, 'scope' => $scope_str);
$url = 'https://secure.' . self::$url_part . '.co.nz/Oauth/RequestToken';
$method = 'POST';
parent::build_request($url, $method, $oauth_fields, array('scope'));
$url .= '?scope=' . $oauth_fields['scope'];
$res = parent::do_request($url, $method);
parse_str($res[0], $res[0]);
if (!isset($res[0]['oauth_token']) || !isset($res[0]['oauth_token_secret'])) {
switch ($res[1]['http_code']) {
case self::TM_ERROR_REQUEST:
$this->last_error = self::TM_ERROR_REQUEST;
break;
case self::TM_ERROR_AUTHENTICATION:
$this->last_error = self::TM_ERROR_AUTHENTICATION;
break;
case self::TM_ERROR_RATE_LIMIT:
$this->last_error = self::TM_ERROR_RATE_LIMIT;
break;
case self::TM_ERROR_GENERIC:
$this->last_error = self::TM_ERROR_GENERIC;
break;
}
return $res;
}
// store token secret
$_SESSION['oauth_token_secret'] = $res[0]['oauth_token_secret'];
// redirect to trademe to get client access token
header('Location: https://secure.' . self::$url_part . '.co.nz/Oauth/Authorize?oauth_token=' . $res[0]['oauth_token']);
exit;
}