Download the PHP package staconik/php-vk-api without Composer

On this page you can find all versions of the php package staconik/php-vk-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-vk-api

php-vk-api

Библиотека для работы с API сайта vk.com

Установка:

composer require staconik/php-vk-api

Пример использования:

$token = new \VKApi\VkAccessToken("ACCESS_TOKEN"); 
if (!$token->check()) {
    echo 'Invalid token';
    exit;
}
$vk = new \VKApi\VkApi($token); //основной класс для работы с апи
$param = new \VKApi\VkParams(["owner_id" => "1"]); //создаем объект параметров запроса
$request = $vk->createRequest("wall.get", $param);
$request->attempts = 5; //количество попыток повторения в случае ошибки
$request->setSuccessListener(function ($response) {
    $items = $response->get()['items'];
    echo "Запрос успешно выполнен!\n";
    echo "Текст первого поста: ".$items[0]['text'];
}); //выполнение кода в случае успеха
$request->setVkErrorListener(function($error){
    echo 'Ошибка: '.$error->error_msg;
});
$result = $request->execute(); //возвращается объект VkResult
//второй вариант обработки результата
if ($result->is_success) {
    echo 'Запрос прошёл успешно [Вариант 2]';
}
if ($result->is_error) {
    echo 'Ошибка запроса [Вариант 2]'.$result->error->error_msg;
} 

Создание авторизации

$auth = new \VKApi\OAuth(['client_id' => "CLIENT_ID", 'scope' => 'offline']); //создаем объект для авторизации и передаем массив параметров

$auth->getImplictFlowLink(); //получение ссылки для авторизации (которая вернет токен)

$auth->getCodeLink(); //получение ссылки для авторизации (на адрес redirect_url будет передан параметр code)

$access_token = $auth->getTokenByCode($code); //получение токена по параметру code. Возвращается объект класса \VKApi\VkAccessToken.

Подробнее про авторизацию читайте в документации VK Api

Загрузка фото:

$upload = new \VKApi\Media\MessagePhotoUpload($vk, "PHOTO_URL", new \VKApi\VkParams()); //параметры в соответствии с документацией
$result = $upload->save(new VkParams()); //возвращается объект photo

Обработка капчи

Необходимо реализовать класс наследник от \VKApi\Handler\BaseCaptchaHandler с реализацией метода getCaptchaKey($vkCaptcha), который должен возвращать ответ, где параметр $vkCaptcha - объект класса \VKApi\VkCaptcha. 

Объект реализованного класса нужно задать с помощью \VKApi\VkApi::setCaptchaHandler($yourHandler)

All versions of php-vk-api with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package staconik/php-vk-api contains the following files

Loading the files please wait ....