Authentication
To work with most of the system's API methods, dual authentication is required: transmitting a cookie and a JWT token.
First of all, you will need an API token, which can be obtained in the Passport section.
The authentication cookie is called AUTH_TICKET
. To obtain it, you need to call the User.login
API method:
curl --location 'https://app.serpzilla.com/login' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
"login": "example@example.com",
"apiToken": "example"
}'
The same operation in PHP:
<?php
$login = "example@example.com";
$apiToken = "example";
$data = json_encode([
"login" => $login,
"apiToken" => $apiToken
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://app.serpzilla.com/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$headers = [
"Content-Type: application/json",
"Accept: application/json"
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
var_export($response);
?>
In response, you get AUTH_TICKET
.
After obtaining AUTH_TICKET
, the next step is to obtain a JSON Web Token (JWT)
.
This is done by calling the User.auth
API method:
curl --location 'https://app.serpzilla.com/auth'
--header 'Accept: application/json'
--header 'Cookie: AUTH_TICKET= XXXXXXXXXXXX'
In response, you receive a JWT.
Authorization is complete. To ensure everything went successfully, you can request the API method "User Info" (User.getInfo
):
curl --location 'https://app.serpzilla.com/rest/User/info'
--header 'Accept: application/json'
--header 'Authorization: Bearer XXXXXXXXXXXX'
--header 'Cookie: AUTH_TICKET= XXXXXXXXXXXX'