protected function getSignedRequest($method, $url, $call, array $additional = array())
    {
        // Get the request/access token
        $token = $this->getToken();
        
        // Generate a random string for the request
        $nonce = md5(microtime(true) . uniqid('', true));
        
        // Prepare the standard request parameters
        $params = array(
            'oauth_consumer_key' => $this->consumerKey,
            'oauth_token' => $token->oauth_token,
            'oauth_signature_method' => $this->sigMethod,
            'oauth_version' => '1.0',
            // Generate nonce and timestamp if signature method is HMAC-SHA1 
            'oauth_timestamp' => ($this->sigMethod == 'HMAC-SHA1') ? time() : null,
            'oauth_nonce' => ($this->sigMethod == 'HMAC-SHA1') ? $nonce : null,
        );
    
        // Merge with the additional request parameters
        $params = array_merge($params, $additional);
        ksort($params);
    
        // URL encode each parameter to RFC3986 for use in the base string
        $encoded = array();
        foreach($params as $param => $value) {
            if ($value !== null) {
                // If the value is a file upload (prefixed with @), replace it with
                // the destination filename, the file path will be sent in POSTFIELDS
                if (isset($value[0]) && $value[0] === '@') $value = $params['filename'];
                $encoded[] = $this->encode($param) . '=' . $this->encode($value);
            } else {
                unset($params[$param]);
            }
        }
        
        // Build the first part of the string
        $base = $method . '&' . $this->encode($url . $call) . '&';
        
        // Re-encode the encoded parameter string and append to $base
        $base .= $this->encode(implode('&', $encoded));

        // Concatenate the secrets with an ampersand
        $key = $this->consumerSecret . '&' . $token->oauth_token_secret;
        
        // Get the signature string based on signature method
        $signature = $this->getSignature($base, $key);
        $params['oauth_signature'] = $signature;
        
        // Build the signed request URL
        $query = '?' . http_build_query($params, '', '&');
        
        return array(
            'url' => $url . $call . $query,
            'postfields' => $params,
        );
    }
protected function getSignedRequest($method, $url, $call, array $additional = array())
    {
        // Get the request/access token
        $token = $this->getToken();
        
        // Generate a random string for the request
        $nonce = md5(microtime(true) . uniqid('', true));
        
        // Prepare the standard request parameters
        $params = array(
            'oauth_consumer_key' => $this->consumerKey,
            'oauth_token' => $token->oauth_token,
            'oauth_signature_method' => $this->sigMethod,
            'oauth_version' => '1.0',
            // Generate nonce and timestamp if signature method is HMAC-SHA1 
            'oauth_timestamp' => ($this->sigMethod == 'HMAC-SHA1') ? time() : null,
            'oauth_nonce' => ($this->sigMethod == 'HMAC-SHA1') ? $nonce : null,
        );
    
        // Merge with the additional request parameters
        $params = array_merge($params, $additional);
        ksort($params);
    
        // URL encode each parameter to RFC3986 for use in the base string
        $encoded = array();
        foreach($params as $param => $value) {
            if ($value !== null) {
                // If the value is a file upload (prefixed with @), replace it with
                // the destination filename, the file path will be sent in POSTFIELDS
                if (isset($value[0]) && $value[0] === '@') $value = $params['filename'];
                $encoded[] = $this->encode($param) . '=' . $this->encode($value);
            } else {
                unset($params[$param]);
            }
        }
        
        // Build the first part of the string
        $base = $method . '&' . $this->encode($url . $call) . '&';
        
        // Re-encode the encoded parameter string and append to $base
        $base .= $this->encode(implode('&', $encoded));

        // Concatenate the secrets with an ampersand
        $key = $this->consumerSecret . '&' . $token->oauth_token_secret;
        
        // Get the signature string based on signature method
        $signature = $this->getSignature($base, $key);
        $params['oauth_signature'] = $signature;
        
        // Build the signed request URL
        $query = '?' . http_build_query($params, '', '&');
        
        return array(
            'url' => $url . $call . $query,
            'postfields' => $params,
        );
    }
protected function getSignedRequest ( $ method , $ url , $ call , array $ additional = array ( ) ) { // Get the request/access token $ token = $ this -> getToken ( ) ; // Generate a random string for the request $ nonce = md5 ( microtime ( true ) . uniqid ( '' , true ) ) ; // Prepare the standard request parameters $ params = array ( 'oauth_consumer_key' => $ this -> consumerKey , 'oauth_token' => $ token -> oauth_token , 'oauth_signature_method' => $ this -> sigMethod , 'oauth_version' => '1.0' , // Generate nonce and timestamp if signature method is HMAC-SHA1  'oauth_timestamp' => ( $ this -> sigMethod == 'HMAC-SHA1' ) ? time ( ) : null , 'oauth_nonce' => ( $ this -> sigMethod == 'HMAC-SHA1' ) ? $ nonce : null , ) ; // Merge with the additional request parameters $ params = array_merge ( $ params , $ additional ) ; ksort ( $ params ) ; // URL encode each parameter to RFC3986 for use in the base string $ encoded = array ( ) ; foreach ( $ params as $ param => $ value ) { if ( $ value !== null ) { // If the value is a file upload (prefixed with @), replace it with // the destination filename, the file path will be sent in POSTFIELDS if ( isset ( $ value [ 0 ] ) && $ value [ 0 ] === '@' ) $ value = $ params [ 'filename' ] ; $ encoded [ ] = $ this -> encode ( $ param ) . '=' . $ this -> encode ( $ value ) ; } else { unset ( $ params [ $ param ] ) ; } } // Build the first part of the string $ base = $ method . '&' . $ this -> encode ( $ url . $ call ) . '&' ; // Re-encode the encoded parameter string and append to $base $ base .= $ this -> encode ( implode ( '&' , $ encoded ) ) ; // Concatenate the secrets with an ampersand $ key = $ this -> consumerSecret . '&' . $ token -> oauth_token_secret ; // Get the signature string based on signature method $ signature = $ this -> getSignature ( $ base , $ key ) ; $ params [ 'oauth_signature' ] = $ signature ; // Build the signed request URL $ query = '?' . http_build_query ( $ params , '' , '&' ) ; return array ( 'url' => $ url . $ call . $ query , 'postfields' => $ params , ) ; }
Generate signed request URL
See inline comments for description
@link http://tools.ietf.org/html/rfc5849#section-3.4
@param string $method HTTP request method
@param string $url API endpoint to send the request to
@param string $call API call to send
@param array $additional Additional parameters as an associative array
@return array
Generate signed request URL See inline comments for description