lib/ThreeScaleClient.php
public function authorize($appId, $appKey = null, $credentials_or_service_id, $usage = null) {
    $url =  $this->getHost() . "/transactions/authorize.xml";
    $params = array('app_id' => $appId);

    if ($credentials_or_service_id instanceof ThreeScaleClientCredentials ) {
      $params['service_token'] = $credentials_or_service_id->service_token;
      $params['service_id'] = $credentials_or_service_id->service_id;
    } else {
      $params['provider_key'] = $this->getProviderKey();
      $params['service_id'] = $credentials_or_service_id;
    }

    if ($appKey) {
      $params['app_key'] = $appKey;
    }
    
    if ($usage) {
      $params['usage'] = $usage;
    }
    
    $httpResponse = $this->httpClient->get($url, $params);
    if (self::isHttpSuccess($httpResponse)) {
      return $this->buildAuthorizeResponse($httpResponse->body);
    } else {
      return $this->processError($httpResponse);
    }
  }
public function authorize($appId, $appKey = null, $credentials_or_service_id, $usage = null) {
    $url =  $this->getHost() . "/transactions/authorize.xml";
    $params = array('app_id' => $appId);

    if ($credentials_or_service_id instanceof ThreeScaleClientCredentials ) {
      $params['service_token'] = $credentials_or_service_id->service_token;
      $params['service_id'] = $credentials_or_service_id->service_id;
    } else {
      $params['provider_key'] = $this->getProviderKey();
      $params['service_id'] = $credentials_or_service_id;
    }

    if ($appKey) {
      $params['app_key'] = $appKey;
    }
    
    if ($usage) {
      $params['usage'] = $usage;
    }
    
    $httpResponse = $this->httpClient->get($url, $params);
    if (self::isHttpSuccess($httpResponse)) {
      return $this->buildAuthorizeResponse($httpResponse->body);
    } else {
      return $this->processError($httpResponse);
    }
  }
Authorize an application for app id auth mode

@param $appId  application id.
@param $appKey secret application key.
@param ThreeScaleClientCredentials $credentials_or_service_id accepts service id and service token as tuple
@param string $credentials_or_service_id accepts only service id

@return ThreeScaleResponse object containing additional authorization information.
If both provider key and application id are valid, the returned object is actually
@see ThreeScaleAuthorizeResponse (which is derived from ThreeScaleResponse) and
contains additional information about the usage status.

@see ThreeScaleResponse
@see ThreeScaleAuthorizeResponse

@throws ThreeScaleServerError in case of unexpected internal server error

Example:

<code>
<?php
$response = $client->authorize('app-id', 'app-key');
// or $response = $client->authorize('app-id', 'app-key', 'service_id');

if ($response->isSuccess()) {
// ok.
} else {
// something is wrong.
}
?>
</code>