PHPackages                             vadimushka/ok-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vadimushka/ok-php-sdk

ActiveLibrary

vadimushka/ok-php-sdk
=====================

OK PHP SDK

2.1.1(5y ago)23972[5 issues](https://github.com/Vadimushka/ok-php-sdk/issues)MITPHPPHP ^8.0CI failing

Since Jul 15Pushed 2y agoCompare

[ Source](https://github.com/Vadimushka/ok-php-sdk)[ Packagist](https://packagist.org/packages/vadimushka/ok-php-sdk)[ Docs](https://github.com/Vadimushka/ok-php-sdk)[ RSS](/packages/vadimushka-ok-php-sdk/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

ok-php-sdk
==========

[](#ok-php-sdk)

PHP library for Ok API interaction, includes OAuth 2.0 authorization and API methods. Full Ok API features documentation can be found [here](https://apiok.ru/).

[![Packagist](https://camo.githubusercontent.com/7082598fb5a9e3c00866875a1eabaa17b671f81b4f389550202de4eed7193195/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766164696d7573686b612f6f6b2d7068702d73646b2e737667)](https://packagist.org/packages/vadimushka/ok-php-sdk)

1. Prerequisites
----------------

[](#1-prerequisites)

- PHP 8.0 or later

2. Installation
---------------

[](#2-installation)

The Ok PHP SDK can be installed using Composer by running the following command:

```
composer require vadimushka/ok-php-sdk
```

3. Initialization
-----------------

[](#3-initialization)

Create OkApiClient object using the following code:

```
$ok = new Client\OkApiClient($application_key, $app_secret_key);
```

4. Authorization
----------------

[](#4-authorization)

The library provides the authorization flows for user based on OAuth 2.0 protocol implementation in apiok.ru. Please read the full [documentation](https://apiok.ru/ext/oauth/) before you start.

### 4.1. Server Authorization Code Flow

[](#41-server-authorization-code-flow)

OAuth 2.0 Authorization Code Flow allows calling methods from the server side.

This flow includes two steps — obtaining an authorization code and exchanging the code for an access token. Primarily you should obtain the "code" ([manual user access](https://apiok.ru/ext/oauth/server)) by redirecting the user to the authorization page using the following method:

Create `OKOAuth` object first:

```
$application_id = 123456789;
$redirect_uri = 'https://example.com/Ok';
$state = 'secret_state_code';
$browser_url = (new Vadimushka\OK\OAuth\OKOAuth)->getAuthorizeUrl(
    response_type: \Vadimushka\OK\OAuth\OkAuthResponseType::CODE,
    application_id: $application_id,
    scope: [
        \Vadimushka\OK\OAuth\OKAuthScope::VALUABLE_ACCESS,
        \Vadimushka\OK\OAuth\OKAuthScope::LONG_ACCESS_TOKEN
    ],
    redirect_uri: $redirect_uri,
    state: $state,
    layout:  \Vadimushka\OK\OAuth\OKOAuth::W
);
```

After successful authorization user's browser will be redirected to the specified redirect\_uri. Meanwhile the code will be sent as a GET parameter to the specified address:

```
https://example.com?code=CODE

```

Then use this method to get the access token:

```
$code = 'CODE';
$application_id = 123456789;
$client_secret = 'client_secret';
$redirect_uri = 'https://example.com/Ok';

$response = (new Vadimushka\OK\OAuth\OKOAuth)->getAccessToken(
    code: $code,
    application_id: $application_id,
    client_secret: $client_secret,
    redirect_uri: $redirect_uri,
);
$access_token = $response->access_token;
```

The **redirect\_uri** should be the URL that was used to get a code at the first step.

### 4.2. Client Authorization Code Flow

[](#42-client-authorization-code-flow)

In difference with server authorization code flow this flow gives you temporary access key.

Read more about [user access key](https://apiok.ru/ext/oauth/client).

First step to get access using Implicit flow is creating OKOAuth object:

```
$application_id = 123456789;
$redirect_uri = 'https://example.com/Ok';
$state = 'secret_state_code';
$browser_url = (new Vadimushka\OK\OAuth\OKOAuth)->getAuthorizeUrl(
    response_type: \Vadimushka\OK\OAuth\OkAuthResponseType::TOKEN,
    application_id: $application_id,
    scope: [
        \Vadimushka\OK\OAuth\OKAuthScope::VALUABLE_ACCESS,
        \Vadimushka\OK\OAuth\OKAuthScope::LONG_ACCESS_TOKEN
    ],
    redirect_uri: $redirect_uri,
    state: $state,
    layout:  \Vadimushka\OK\OAuth\OKOAuth::W
);
```

Arguments are similar with server authorization code flow

After successful authorization user's browser will be redirected to the specified redirect\_uri. Meanwhile, the access token will be sent as a fragment parameter to the specified address:

```
https://example.com/#access_token={access_token}&session_secret_key={session_secret_key}&state={state}&permissions_granted={permissions_granted}&expires_in={expires_in}

```

**access\_token** is your new access token. **session\_secret\_key** is secret session key. **expires\_in** is lifetime of access token in seconds. **permissions\_granted** is rights granted by the user to the application. **state** is string from authorize method.

5. API Requests
---------------

[](#5-api-requests)

You can find the full list of OK API methods [here](https://apiok.ru/dev/methods/rest/).

### 5.1. Request sample

[](#51-request-sample)

### 5.2. Uploading Photos into a Private Message

[](#52-uploading-photos-into-a-private-message)

### 5.3. Uploading Video Files

[](#53-uploading-video-files)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~94 days

Total

4

Last Release

1845d ago

Major Versions

v1.1 → 2.1.02021-04-24

PHP version history (2 changes)v1.0PHP &gt;=7.1

2.1.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/480cefd0eb5d70db560d7884a4ff82d123031a6339a6fdf0b64c9384ff1cd687?d=identicon)[vadimushka\_d](/maintainers/vadimushka_d)

---

Top Contributors

[![Vadimushka](https://avatars.githubusercontent.com/u/6237552?v=4)](https://github.com/Vadimushka "Vadimushka (20 commits)")

---

Tags

sdkOK

### Embed Badge

![Health badge](/badges/vadimushka-ok-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/vadimushka-ok-php-sdk/health.svg)](https://phpackages.com/packages/vadimushka-ok-php-sdk)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k511.3M2.2k](/packages/aws-aws-sdk-php)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[azure-oss/storage

Azure Blob Storage PHP SDK

37985.0k5](/packages/azure-oss-storage)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

27539.9k1](/packages/yoti-yoti-php-sdk)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
