You are here

public function Client::post in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/vendor/maxmind/web-service-common/src/WebService/Client.php \MaxMind\WebService\Client::post()

Parameters

string $service name of the service querying:

string $path the URI path to use:

array $input the data to be posted as JSON:

Return value

array The decoded content of a successful response

Throws

InvalidInputException when the request has missing or invalid data.

AuthenticationException when there is an issue authenticating the request.

InsufficientFundsException when your account is out of funds.

InvalidRequestException when the request is invalid for some other reason, e.g., invalid JSON in the POST.

HttpException when an unexpected HTTP error occurs.

WebServiceException when some other error occurs. This also serves as the base class for the above exceptions.

File

includes/vendor/maxmind/web-service-common/src/WebService/Client.php, line 100

Class

Client
This class is not intended to be used directly by an end-user of a MaxMind web service. Please use the appropriate client API for the service that you are using. @package MaxMind\WebService @internal

Namespace

MaxMind\WebService

Code

public function post($service, $path, $input) {
  $body = json_encode($input);
  if ($body === false) {
    throw new InvalidInputException('Error encoding input as JSON: ' . $this
      ->jsonErrorDescription());
  }
  $request = $this
    ->createRequest($path, array(
    'Content-Type: application/json',
  ));
  list($statusCode, $contentType, $body) = $request
    ->post($body);
  return $this
    ->handleResponse($statusCode, $contentType, $body, $service, $path);
}