PHP code example of darkdarin / vk-ord-sdk

1. Go to this page and download the library: Download darkdarin/vk-ord-sdk 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/ */

    

darkdarin / vk-ord-sdk example snippets


use DarkDarin\VkOrdSdk\TransportClient\TransportClient;
use DarkDarin\VkOrdSdk\Factories\PsrClientFactory;
use DarkDarin\VkOrdSdk\Factories\PsrRequestFactoryFactory;
use DarkDarin\VkOrdSdk\Factories\PsrStreamFactoryFactory;
use DarkDarin\Serializer\ApiSerializer\ApiSerializerFactory;
use DarkDarin\Serializer\MethodParametersSerializer\MethodParametersMapper;
use DarkDarin\VkOrdSdk\VkOrd;

$transportClient = new TransportClient(
    (new PsrClientFactory())(),
    (new PsrRequestFactoryFactory())(),
    (new PsrStreamFactoryFactory())(),
    (new ApiSerializerFactory())(),
    new MethodParametersMapper()
);

$vkClient = new VkOrd('https://api.ord.vk.com', 'TOKEN', $transportClient);

$contract = $vkClient->getContract('5t33p36p8p-1h57fjo00');

use Illuminate\Support\Facades\App;
use DarkDarin\VkOrdSdk\VkOrd;

// Получить сконфигурированный клиент можно через DI любым доступным способом
// https://laravel.com/docs/10.x/container
$vkClient = App::make(VkOrd::class);
$contract = $vkClient->getContract('5t33p36p8p-1h57fjo00');

use Hyperf\Context\ApplicationContext;
use DarkDarin\VkOrdSdk\VkOrd;

// Получить сконфигурированный клиент можно через DI любым доступным способом
// https://hyperf.wiki/3.0/#/en/di
$vkClient = ApplicationContext::getContainer()->get(VkOrd::class);
$contract = $vkClient->getContract('5t33p36p8p-1h57fjo00');

/** @var \DarkDarin\VkOrdSdk\VkOrd $vkClient **/
$contract = $vkClient->withUrl('https://api-sandbox.ord.vk.com')
    ->withToken('SANDBOX_TOKEN')
    ->getContract('5t33p36p8p-1h57fjo00');
bash
php artisan vendor:publish --provider "DarkDarin\VkOrdSdk\VkOrdSdkServiceProvider"
bash
php bin/hyperf.php vendor:publish darkdarin/vk-ord-sdk