Ignore:
Timestamp:
Jan 9, 2014, 6:11:33 PM (10 years ago)
Author:
mistic100
Message:

update Hybridauth, update guides

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/include/hybridauth/Hybrid/Providers/Twitter.php

    r20293 r26555  
    1818                parent::initialize();
    1919
    20                 // Provider api end-points
    21                 $this->api->api_base_url      = "https://api.twitter.com/1/";
     20                // Provider api end-points 
     21                $this->api->api_base_url      = "https://api.twitter.com/1.1/";
    2222                $this->api->authorize_url     = "https://api.twitter.com/oauth/authenticate";
    2323                $this->api->request_token_url = "https://api.twitter.com/oauth/request_token";
    2424                $this->api->access_token_url  = "https://api.twitter.com/oauth/access_token";
    2525
     26                if ( isset( $this->config['api_version'] ) && $this->config['api_version'] ){
     27                        $this->api->api_base_url  = "https://api.twitter.com/{$this->config['api_version']}/";
     28                }
     29 
     30                if ( isset( $this->config['authorize'] ) && $this->config['authorize'] ){
     31                        $this->api->authorize_url = "https://api.twitter.com/oauth/authorize";
     32                }
     33
    2634                $this->api->curl_auth_header  = false;
    2735        }
     36
     37        /**
     38         * begin login step
     39         */
     40        function loginBegin()
     41        {
     42                $tokens = $this->api->requestToken( $this->endpoint );
     43       
     44                // request tokens as recived from provider
     45                $this->request_tokens_raw = $tokens;
     46       
     47                // check the last HTTP status code returned
     48                if ( $this->api->http_code != 200 ){
     49                        throw new Exception( "Authentification failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 5 );
     50                }
     51       
     52                if ( ! isset( $tokens["oauth_token"] ) ){
     53                        throw new Exception( "Authentification failed! {$this->providerId} returned an invalid oauth token.", 5 );
     54                }
     55       
     56                $this->token( "request_token"       , $tokens["oauth_token"] );
     57                $this->token( "request_token_secret", $tokens["oauth_token_secret"] );
     58       
     59                // redirect the user to the provider authentication url with force_login
     60                if ( isset( $this->config['force_login'] ) && $this->config['force_login'] ){
     61                        Hybrid_Auth::redirect( $this->api->authorizeUrl( $tokens, array( 'force_login' => true ) ) );
     62                }
     63
     64                // else, redirect the user to the provider authentication url
     65                Hybrid_Auth::redirect( $this->api->authorizeUrl( $tokens ) );
     66        }
    2867
    2968        /**
Note: See TracChangeset for help on using the changeset viewer.