You are here

public static function OAuthUtil::parse_parameters 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::parse_parameters()
5 calls to OAuthUtil::parse_parameters()
OAuthRequest::from_request in src/Twitter/OAuthRequest.php
attempt to build up a request from what was passed to the server
OAuthRequest::__construct in src/Twitter/OAuthRequest.php
TwitterOAuth::getAccessToken in src/Twitter/TwitterOAuth.php
Exchange request token and secret for an access token and secret, to sign API calls.
TwitterOAuth::getRequestToken in src/Twitter/TwitterOAuth.php
Get a request_token from Twitter
TwitterOAuth::getXAuthToken in src/Twitter/TwitterOAuth.php
One time exchange of username and password for access token and secret.

File

src/Twitter/OAuthUtil.php, line 108

Class

OAuthUtil

Namespace

Drupal\jquery_social_stream\Twitter

Code

public static function parse_parameters($input) {
  if (!isset($input) || !$input) {
    return array();
  }
  $pairs = explode('&', $input);
  $parsed_parameters = array();
  foreach ($pairs as $pair) {
    $split = explode('=', $pair, 2);
    $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
    $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
    if (isset($parsed_parameters[$parameter])) {

      // We have already recieved parameter(s) with this name, so add to the list
      // of parameters with this name
      if (is_scalar($parsed_parameters[$parameter])) {

        // This is the first duplicate, so transform scalar (string) into an array
        // so we can add the duplicates
        $parsed_parameters[$parameter] = array(
          $parsed_parameters[$parameter],
        );
      }
      $parsed_parameters[$parameter][] = $value;
    }
    else {
      $parsed_parameters[$parameter] = $value;
    }
  }
  return $parsed_parameters;
}