src/Twitter/Connections/AppConnection.php
public function createBearerToken()
    {
        //get bearer token credentials - to be used for getting the bearer token from Twitter.
        $bearerCredentials = $this->createBearerCredentials();

        //Required Headers
        $headers = array(
            'Authorization' => 'Basic ' . $bearerCredentials,
            'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
        );

        //Required Body
        $body = 'grant_type=client_credentials';

        //Send a Post request to `oauth2/token` and convert the resulting JSON to assoc-array.
        $data = $this->guzzleClient->post(
                Config::get('oauth2_token'),
                array(
                    'headers' => $headers,
                    'body' => $body
                )
            )->json();

        //Set the bearer token in the AppCredentials object
        $this->credentials->setBearerToken($data['access_token']);

        //Return the current object
        return $this;
    }
public function createBearerToken()
    {
        //get bearer token credentials - to be used for getting the bearer token from Twitter.
        $bearerCredentials = $this->createBearerCredentials();

        //Required Headers
        $headers = array(
            'Authorization' => 'Basic ' . $bearerCredentials,
            'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
        );

        //Required Body
        $body = 'grant_type=client_credentials';

        //Send a Post request to `oauth2/token` and convert the resulting JSON to assoc-array.
        $data = $this->guzzleClient->post(
                Config::get('oauth2_token'),
                array(
                    'headers' => $headers,
                    'body' => $body
                )
            )->json();

        //Set the bearer token in the AppCredentials object
        $this->credentials->setBearerToken($data['access_token']);

        //Return the current object
        return $this;
    }
public function createBearerToken ( ) { //get bearer token credentials - to be used for getting the bearer token from Twitter. $ bearerCredentials = $ this -> createBearerCredentials ( ) ; //Required Headers $ headers = array ( 'Authorization' => 'Basic ' . $ bearerCredentials , 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' ) ; //Required Body $ body = 'grant_type=client_credentials' ; //Send a Post request to `oauth2/token` and convert the resulting JSON to assoc-array. $ data = $ this -> guzzleClient -> post ( Config :: get ( 'oauth2_token' ) , array ( 'headers' => $ headers , 'body' => $ body ) ) -> json ( ) ; //Set the bearer token in the AppCredentials object $ this -> credentials -> setBearerToken ( $ data [ 'access_token' ] ) ; //Return the current object return $ this ; }
Calls Twitter and gets a bearer token. This bearer token is valid until it gets invalidated.

@link https://dev.twitter.com/docs/auth/application-only-auth Bearer Token Description

@return $this AppConnection
Calls Twitter and gets a bearer token . This bearer token is valid until it gets invalidated .