You are here

protected function ServicesClientConnectionOAuthAuth::getRequestParams in Services Client 7.2

Same name and namespace in other branches
  1. 7 services_client_connection/modules/services_client_oauth/plugins/ServicesClientConnectionOAuthAuth.inc \ServicesClientConnectionOAuthAuth::getRequestParams()

Determine which params should be included in signing

Parameters

ServicesClientConnectionHttpRequest $request:

1 call to ServicesClientConnectionOAuthAuth::getRequestParams()
ServicesClientConnectionOAuthAuth::sign in services_client_connection/modules/services_client_oauth/plugins/ServicesClientConnectionOAuthAuth.inc
Authenticate request

File

services_client_connection/modules/services_client_oauth/plugins/ServicesClientConnectionOAuthAuth.inc, line 158

Class

ServicesClientConnectionOAuthAuth
OAuth authentication support

Code

protected function getRequestParams(ServicesClientConnectionHttpRequest &$request) {
  $params = NULL;

  // If GET request take any $req->data params
  if ($request->http_method == 'GET' && is_array($request->data) && !empty($request->data)) {
    $params = $request->data;
  }

  // Try to guess whether POST request contains data encoded by http_build_query
  // which could be assigned to signature on remote site.
  if ($request->http_method == 'POST' && is_array($request->data_raw) && !empty($request->data_raw) && isset($request->http_headers['Content-Type']) && $request->http_headers['Content-Type'] == 'application/x-www-form-urlencoded') {

    // If post URL is comming with Query
    $data = $request->data;
    if (!empty($request->query)) {
      if ($data) {
        $data .= '&';
      }
      $data .= http_build_query($request->query, NULL, '&');
    }
    $params = OAuthUtil::parse_parameters($data);
    if (count($params) == 1) {
      $params = array_filter($params);
    }
  }

  // Flatten array keys
  if (is_array($params) && !empty($params)) {
    $params = $this
      ->flattenParamKeys($params);
  }
  return $params;
}