OAuth PHP cURL GET Request


I’m making an OAuth library and am running across an issue with the Twitter implementation. While what I have already works for Flickr, and is returning the right access tokens and keys, when I make the request to the Twitter API for information, I receive the ambiguous Code 32: “Could not authenticate you”.

Could anyone have a look at the code below and point out where it’s going wrong? As said earlier, I believe it must be this step as the other steps are the same with flickr and are working fine, but this step is dealt with differently:

$oauth = array('oauth_consumer_key' => 'key',
          'oauth_signature_method' => 'HMAC-SHA1',
          'oauth_timestamp' => 1415633132,
          'oauth_nonce' => 1817099296,
          'oauth_version' => '1.0', 
		  'oauth_token' => token',
		  'oauth_signature' => 'signature'

function buildAuthorizationHeader($oauth){
    $r = 'Authorization: OAuth '; 
    $values = array(); //temporary key=value array
    foreach($oauth as $key=>$value)
        $values[] = "$key=\"" . rawurlencode($value) . "\""; 
    $r .= implode(',', $values);
    return $r; 
function sendRequest($oauth){
    $header = array( buildAuthorizationHeader($oauth), 'Expect:'); 
    $options = array(CURLOPT_HTTPHEADER => $header, 
                           CURLOPT_HEADER => false,
                           CURLOPT_URL => 'https://api.twitter.com/1.1/search/tweets.json?q=london',
                           CURLOPT_SSL_VERIFYPEER => false); 
    $ch = curl_init(); 
    curl_setopt_array($ch, $options);
    $response = curl_exec($ch);
    return $response;