You are here

public static function OAuthUtil::split_header in jQuery social stream 8

Same name and namespace in other branches
  1. 8.2 src/Twitter/OAuthUtil.php \Drupal\jquery_social_stream\Twitter\OAuthUtil::split_header()
1 call to OAuthUtil::split_header()
OAuthRequest::from_request in src/Twitter/OAuthRequest.php
attempt to build up a request from what was passed to the server

File

src/Twitter/OAuthUtil.php, line 35

Class

OAuthUtil

Namespace

Drupal\jquery_social_stream\Twitter

Code

public static function split_header($header, $only_allow_oauth_parameters = true) {
  $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
  $offset = 0;
  $params = array();
  while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
    $match = $matches[0];
    $header_name = $matches[2][0];
    $header_content = isset($matches[5]) ? $matches[5][0] : $matches[4][0];
    if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
      $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
    }
    $offset = $match[1] + strlen($match[0]);
  }
  if (isset($params['realm'])) {
    unset($params['realm']);
  }
  return $params;
}