1. Go to this page and download the library: Download professionali/api-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
professionali / api-client example snippets
session_start();
// Создаем API клиента
$client = new Pro_Api_Client(
APP_CODE, // код приложения
APP_SECRET, // секретный ключ приложения
$_SESSION['token'],
$_SESSION['expires']
);
// Редирект с авторизации приложения с токеном
if (!empty($_GET['code'])) {
$client->getAccessTokenFromCode($_GET['code']);
// Редиректим на себя же, чтоб убрать код из GET параметра
header('Location: http://'.$_SERVER['HTTP_HOST'], true, 301);
exit;
}
// Авторизация приложения
if (!$client->getAccessToken()) {
header('Location: '.$client->getAuthenticationUrl('http://'.$_SERVER['HTTP_HOST']), true, 301);
exit;
}
// Здесь приложение уже авторизовано и можно им пользоваться
echo '<pre>';
echo 'AccessToken: '.$client->getAccessToken()."\n";
echo 'CurrentUser: '.print_r($client->getCurrentUser(), true);
echo '</pre>';