You are here

public function OAuthRequest::to_header in jQuery social stream 8

Same name and namespace in other branches
  1. 8.2 src/Twitter/OAuthRequest.php \Drupal\jquery_social_stream\Twitter\OAuthRequest::to_header()

builds the Authorization: header

File

src/Twitter/OAuthRequest.php, line 209

Class

OAuthRequest

Namespace

Drupal\jquery_social_stream\Twitter

Code

public function to_header($realm = null) {
  $first = true;
  if ($realm) {
    $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
    $first = false;
  }
  else {
    $out = 'Authorization: OAuth';
  }
  $total = array();
  foreach ($this->parameters as $k => $v) {
    if (substr($k, 0, 5) != "oauth") {
      continue;
    }
    if (is_array($v)) {
      throw new OAuthException('Arrays not supported in headers');
    }
    $out .= $first ? ' ' : ',';
    $out .= OAuthUtil::urlencode_rfc3986($k) . '="' . OAuthUtil::urlencode_rfc3986($v) . '"';
    $first = false;
  }
  return $out;
}