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


PHP tmhOAuth::apponly_request方法代码示例

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


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

示例1: isAccessTokenValid

 /**
  * Checks if the authentication credentials currently stored in hydra.yml are correct or not.
  *
  * @return boolean
  */
 public function isAccessTokenValid()
 {
     if (empty($this->authentication['bearer'])) {
         return false;
     }
     $this->api->apponly_request(array('method' => 'GET', 'url' => $this->api->url('youtube/v3/activities', ''), 'params' => array('part' => 'id', 'mine' => 'true')));
     // HTTP 200 means we were successful
     return $this->api->response['code'] == 200;
 }
开发者ID:beecms,项目名称:virtual-identity,代码行数:14,代码来源:YoutubeService.php

示例2: getAuthenticationUrl

 /**
  * @return string
  * @throws Exception
  */
 public function getAuthenticationUrl()
 {
     $authConf = Config::$a['oauth']['providers'][$this->authProvider];
     $callback = sprintf(Config::$a['oauth']['callback'], $this->authProvider);
     $tmhOAuth = new \tmhOAuth(array('consumer_key' => $authConf['clientId'], 'consumer_secret' => $authConf['clientSecret'], 'token' => $authConf['token'], 'secret' => $authConf['secret'], 'curl_connecttimeout' => Config::$a['curl']['connecttimeout'], 'curl_timeout' => Config::$a['curl']['timeout'], 'curl_ssl_verifypeer' => Config::$a['curl']['verifypeer']));
     $code = $tmhOAuth->apponly_request(array('without_bearer' => true, 'method' => 'POST', 'url' => $tmhOAuth->url('oauth/request_token', ''), 'params' => array('oauth_callback' => $callback)));
     if ($code != 200) {
         throw new Exception('There was an error communicating with Twitter.');
     }
     $response = $tmhOAuth->extract_params($tmhOAuth->response['response']);
     if ($response['oauth_callback_confirmed'] !== 'true') {
         throw new Exception('The callback was not confirmed by Twitter so we cannot continue.');
     }
     Session::set('oauth', $response);
     return $tmhOAuth->url('oauth/authorize', '') . "?oauth_token={$response['oauth_token']}";
 }
开发者ID:TonyWoo,项目名称:website,代码行数:20,代码来源:TwitterAuthHandler.php

示例3: 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

示例4: tmhOAuth

<?php

session_name("OAuth");
session_start();
require_once 'config.php';
require_once 'tmhOAuth.php';
if (isset($_REQUEST['id'])) {
    $_SESSION['id'] = $_REQUEST['id'];
}
if (!isset($_REQUEST['oauth_verifier'])) {
    // Step 1: Request a temporary token and
    // Step 2: Direct the user to the authorize web page
    $tmhOAuth = new tmhOAuth(array('consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET));
    $callback_url = "http" . (!empty($_SERVER['HTTPS']) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    $code = $tmhOAuth->apponly_request(array('without_bearer' => true, 'method' => 'POST', 'url' => $tmhOAuth->url('oauth/request_token', ''), 'params' => array('oauth_callback' => $callback_url)));
    if ($code != 200) {
        error("There was an error communicating with Twitter. {$tmhOAuth->response['response']}");
        return;
    }
    // store the params into the session so they are there when we come back after the redirect
    $_SESSION['oauth'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
    // check the callback has been confirmed
    if ($_SESSION['oauth']['oauth_callback_confirmed'] !== 'true') {
        error('The callback was not confirmed by Twitter so we cannot continue.');
    } else {
        $url = $tmhOAuth->url('oauth/authorize', '') . "?oauth_token={$_SESSION['oauth']['oauth_token']}";
        header("Location: " . $url);
        exit;
    }
} else {
    // Step 3: This is the code that runs when Twitter redirects the user to the callback. Exchange the temporary token for a permanent access token
开发者ID:n0madic,项目名称:vk2twitter,代码行数:31,代码来源:get_access_token.php

示例5: post

 public function post($method, $params)
 {
     $code = $this->api->apponly_request(array('without_bearer' => true, 'method' => 'POST', 'url' => $this->api->url($method, ''), 'params' => $params));
     $response = array('code' => $code, 'data' => $this->api->response['response']);
     return $response;
 }
开发者ID:nicokaag,项目名称:social-scrape-bundle,代码行数:6,代码来源:Twitter.php


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