PHP. Make your first call.
Install the official PHP client and bring ParseAPI into your code.
Official PHP SDK
composer require parseapi/sdkYour language. The same ParseAPI.
Get connected
One country. Your first request.
Look up the United States and print its name.
Install the library.
composer require parseapi/sdkAdd your secret key.
Create a secret key in Keys. Set it in the terminal that will run the example. Keep it on your server.
export PARSEAPI_KEY='YOUR_API_KEY'Make a request.
Save this as example.php, then run it. This lookup uses your plan's request allowance.
<?php
require __DIR__ . '/vendor/autoload.php';
use ParseAPI\Client;
$parse = new Client(); // Reads PARSEAPI_KEY.
try {
$country = $parse->country('US');
echo $country['name'] . PHP_EOL;
} finally {
$parse->close();
}php example.phpUnited StatesHandle API errors
Read the error code and request ID when an API request fails. Branch on the code, such as not_found, rather than the message. A response with valid: false is a successful lookup. Transport failures still propagate.
<?php
require __DIR__ . '/vendor/autoload.php';
use ParseAPI\Client;
use ParseAPI\ParseAPIError;
$parse = new Client(); // Reads PARSEAPI_KEY.
try {
$country = $parse->country('US');
echo $country['name'] . PHP_EOL;
} catch (ParseAPIError $error) {
error_log($error->errorCode . ' ' . $error->status . ' ' . $error->requestId);
throw $error;
} finally {
$parse->close();
}Requests and retries
SDK methods follow the API routes. Unknown response values stay unknown, rather than becoming empty strings or guesses.
Ordinary lookups retry temporary failures. Separately metered checks make one attempt by default. You can configure the retry count. See the retry policy.