You are here

public static function sOAuthUtil::parse_parameters in jQuery social stream 7

Same name and namespace in other branches
  1. 7.2 jquery_social_stream.js.inc \sOAuthUtil::parse_parameters()
5 calls to sOAuthUtil::parse_parameters()
sOAuthRequest::from_request in ./jquery_social_stream.js.inc
attempt to build up a request from what was passed to the server
sOAuthRequest::__construct in ./jquery_social_stream.js.inc
TwittersOAuth::getAccessToken in ./jquery_social_stream.js.inc
Exchange request token and secret for an access token and secret, to sign API calls.
TwittersOAuth::getRequestToken in ./jquery_social_stream.js.inc
Get a request_token from Twitter
TwittersOAuth::getXAuthToken in ./jquery_social_stream.js.inc
One time exchange of username and password for access token and secret.

File

./jquery_social_stream.js.inc, line 1156
JS callbacks.

Class

sOAuthUtil

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 = sOAuthUtil::urldecode_rfc3986($split[0]);
    $value = isset($split[1]) ? sOAuthUtil::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;
}