当前位置: 首页>>代码示例>>PHP>>正文


PHP parent::oauth_settings方法代码示例

本文整理汇总了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;
 }
开发者ID:mitni455,项目名称:trademe-api-basic,代码行数:63,代码来源:trademeApiRequest.php


注:本文中的parent::oauth_settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。