Authentication
In this section, you will learn how to properly access the API via API login and password.

Login credentials

To start working with the API, you must have an API login and password (don't confuse login and password from mobile-calendar account).

How to get credentials data?

  1. 2.
    Go to Synchronization > Rest API.
  2. 3.
    At this point, you receive your login details.

API account authentication - Basic Auth

The API uses the underlying HTTP authentication scheme. You must include an Authorization header with each mobile-calendar API query.
1
Authorization: Basic {username:password}
Copied!

An example of cURL request in PHP

The following script gets prices for the date range 1/1/2021 - 1/31/2021. Including the header is visible on line 10.
1
function sampleRequest()
2
{
3
define(USERNAME, '[email protected]************************');
4
define(PASSWORD, 'SJbVx^[email protected]*****************************');
5
$url = 'htttps://app.mobile-calendar.com/api/get/pricing';
6
7
$ch = curl_init($url);
8
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
9
curl_setopt($ch, CURLOPT_POST, true);
10
curl_setopt($ch, CURLOPT_USERPWD, USERNAME. ":" .PASSWORD);
11
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
12
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
13
"from" => "2021-01-01",
14
"to" => "2021-01-31"
15
]));
16
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
17
$result = curl_exec($ch);
18
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
19
curl_close($ch);
20
return ['body' => $result, 'httpcode' => $httpcode];
21
}
Copied!
Remember to add a header: Content-Type: application/json

Authorization error

The authorization error returns the error code 401 Unauthorized and the JSON response shown below:
1
{
2
"status": "error",
3
"errors": "Wrong credentials"
4
}
Copied!

Troubleshooting

  • Make sure your request includes an Authorization header
  • Make sure that you have entered the correct login credentials (API login and password)
  • Make sure you have entered a valid URL
You have a problem? contact us: [email protected]