You are here

private function TwitterAPIExchange::buildAuthorizationHeader in Twitter Profile Widget 8.2

Same name and namespace in other branches
  1. 8 src/Resources/j7mbo/twitter_api_php/TwitterAPIExchange.php \Drupal\twitter_profile_widget\Resources\j7mbo\twitter_api_php\TwitterAPIExchange::buildAuthorizationHeader()

Private method to generate authorization header used by cURL

Parameters

array $oauth Array of oauth data generated by buildOauth():

Return value

string $return Header used by cURL for request

1 call to TwitterAPIExchange::buildAuthorizationHeader()
TwitterAPIExchange::performRequest in src/Resources/j7mbo/twitter_api_php/TwitterAPIExchange.php
Perform the actual data retrieval from the API

File

src/Resources/j7mbo/twitter_api_php/TwitterAPIExchange.php, line 352

Class

TwitterAPIExchange
Twitter-API-PHP : Simple PHP wrapper for the v1.1 API

Namespace

Drupal\twitter_profile_widget\Resources\j7mbo\twitter_api_php

Code

private function buildAuthorizationHeader(array $oauth) {
  $return = 'Authorization: OAuth ';
  $values = [];
  foreach ($oauth as $key => $value) {
    if (in_array($key, [
      'oauth_consumer_key',
      'oauth_nonce',
      'oauth_signature',
      'oauth_signature_method',
      'oauth_timestamp',
      'oauth_token',
      'oauth_version',
    ])) {
      $values[] = "{$key}=\"" . rawurlencode($value) . "\"";
    }
  }
  $return .= implode(', ', $values);
  return $return;
}