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


PHP tmhOAuth::reconfigure方法代码示例

本文整理汇总了PHP中tmhOAuth::reconfigure方法的典型用法代码示例。如果您正苦于以下问题:PHP tmhOAuth::reconfigure方法的具体用法?PHP tmhOAuth::reconfigure怎么用?PHP tmhOAuth::reconfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tmhOAuth的用法示例。


在下文中一共展示了tmhOAuth::reconfigure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 function authorize_twitter()
 {
     if (!App::import('Lib', 'tmh_oauth')) {
         $this->Session->setFlash(sprintf(__('Failed to load the %s library! Contact your system administrator.', true), 'Twitter OAuth'), 'default', array('class' => 'error'));
         $this->redirect(array('action' => 'preferences'));
     }
     define('__DIR__', ROOT . DS . APP_DIR . DS . 'libs');
     $tmhOAuth = new tmhOAuth(array('consumer_key' => Configure::read('twitter.consumer_key'), 'consumer_secret' => Configure::read('twitter.consumer_secret')));
     if (!empty($this->params['url']['oauth_token'])) {
         $response = $this->Session->read('Twitter.response');
         $this->Session->delete('Twitter.response');
         if ($this->params['url']['oauth_token'] !== $response['oauth_token']) {
             $this->Session->setFlash(__('The oauth token you started with doesn\'t match the one you\'ve been redirected with. Do you have multiple tabs open?', true), 'default', array('class' => 'warning'));
             $this->redirect(array('action' => 'preferences'));
         }
         if (!isset($this->params['url']['oauth_verifier'])) {
             $this->Session->setFlash(__('The oauth verifier is missing so we cannot continue. Did you deny the appliction access?', true), 'default', array('class' => 'warning'));
             $this->redirect(array('action' => 'preferences'));
         }
         // Update with the temporary token and secret
         $tmhOAuth->reconfigure(array_merge($tmhOAuth->config, array('token' => $response['oauth_token'], 'secret' => $response['oauth_token_secret'])));
         $code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('oauth/access_token', ''), 'params' => array('oauth_verifier' => trim($this->params['url']['oauth_verifier']))));
         if ($code == 200) {
             $oauth_creds = $tmhOAuth->extract_params($tmhOAuth->response['response']);
             if ($this->Person->updateAll(array('twitter_token' => "'{$oauth_creds['oauth_token']}'", 'twitter_secret' => "'{$oauth_creds['oauth_token_secret']}'"), array('Person.id' => $this->UserCache->currentId()))) {
                 $this->Session->setFlash(sprintf(__('Your Twitter authorization has been completed. You can always revoke this at any time through the preferences page.', true), __('person', true)), 'default', array('class' => 'success'));
             } else {
                 $this->Session->setFlash(sprintf(__('Twitter authorization was received, but the database failed to update.', true), __('person', true)), 'default', array('class' => 'warning'));
             }
         } else {
             $this->Session->setFlash(__('There was an error communicating with Twitter.', true) . ' ' . $tmhOAuth->response['response'], 'default', array('class' => 'warning'));
         }
         $this->redirect(array('action' => 'preferences'));
     } else {
         $code = $tmhOAuth->apponly_request(array('without_bearer' => true, 'method' => 'POST', 'url' => $tmhOAuth->url('oauth/request_token', ''), 'params' => array('oauth_callback' => Router::url(Router::normalize($this->here), true))));
         if ($code != 200) {
             $this->Session->setFlash(__('There was an error communicating with Twitter.', true) . ' ' . $tmhOAuth->response['response'], 'default', array('class' => 'warning'));
             $this->redirect(array('action' => 'preferences'));
         }
         // store the params into the session so they are there when we come back after the redirect
         $response = $tmhOAuth->extract_params($tmhOAuth->response['response']);
         // check the callback has been confirmed
         if ($response['oauth_callback_confirmed'] !== 'true') {
             $this->Session->setFlash(__('The callback was not confirmed by Twitter so we cannot continue.', true) . ' ' . $tmhOAuth->response['response'], 'default', array('class' => 'warning'));
             $this->redirect(array('action' => 'preferences'));
         } else {
             $this->Session->write('Twitter.response', $response);
             $this->redirect($tmhOAuth->url('oauth/authorize', '') . "?oauth_token={$response['oauth_token']}");
         }
     }
 }
开发者ID:roboshed,项目名称:Zuluru,代码行数:51,代码来源:people_controller.php

示例2: reconfig

 /**
  * Set new config values for the OAuth class like different tokens.
  *
  * @param Array $config An array containing the values that should be
  *     overwritten.
  *
  * @return void
  */
 public function reconfig($config)
 {
     // The consumer key and secret must always be included when reconfiguring
     $config = array_merge($this->parent_config, $config);
     parent::reconfigure($config);
     return $this;
 }
开发者ID:cvepdb-cms,项目名称:module-posts,代码行数:15,代码来源:Twitter.php


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