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. Go to Synchronization > Rest API.

  2. 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.

Authorization: Basic {username:password}

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.

function sampleRequest()
{
	define(USERNAME, 'info@mobile-calendar.com************************');
	define(PASSWORD, 'SJbVx^Xqty6FQlE9@4P*****************************');
	$url = 'htttps://api.mobile-calendar.com/get/pricing';
	
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_USERPWD, USERNAME. ":" .PASSWORD);
	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
		"from" => "2021-01-01", 
		"to"   => "2021-01-31"
	]));
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$result = curl_exec($ch);
	$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	curl_close($ch);
	return ['body' => $result, 'httpcode' => $httpcode];
}

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:

{
    "status": "error",
    "errors": "Wrong credentials"
}

Troubleshooting

You have a problem? contact us: info@mobile-calendar.com

Last updated