PHPackages                             koma136/mytarget-sdk-php - 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. [API Development](/categories/api)
4. /
5. koma136/mytarget-sdk-php

ActiveLibrary[API Development](/categories/api)

koma136/mytarget-sdk-php
========================

API bindings for MyTarget

3.0.3(7y ago)11.2k1Apache-2.0PHP

Since Aug 10Pushed 7y ago2 watchersCompare

[ Source](https://github.com/koma136/mytarget-sdk-php)[ Packagist](https://packagist.org/packages/koma136/mytarget-sdk-php)[ RSS](/packages/koma136-mytarget-sdk-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (10)Versions (27)Used By (0)

Unofficial MyTarget API Client
==============================

[](#unofficial-mytarget-api-client)

PHP клиент для работы с MyTarget API (v1/v2). SDK использует объекты Yii 2

### Install it via composer

[](#install-it-via-composer)

```
composer require koma136/my-target-sdk

```

fork dsl/my-target-sdk

Для Yii 2 в index.php пишем:

$autoloader = require(**DIR** . '/../../vendor/autoload.php'); \\Doctrine\\Common\\Annotations\\AnnotationRegistry::registerLoader(\[$autoloader, 'loadClass'\]);

Добавлен TopMailOperator для создания счетчиков top.mail.ru, нужно при организации ремаркетинга. Основанно на супер документации ))

### Пример пролучения ключа с обновлением

[](#пример-пролучения-ключа-с-обновлением)

```
use Koma136\MyTarget\Token\Token;
use Koma136\MyTarget\Operator\V2\TokenOperator;
use Koma136\MyTarget\Client;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Uri;

$array_token =
[
    'access' => BJJHBKBUIHJMNGJHVBJKNJLHJKHJFDSDBFBFHMGHNCXFGHCFYJVDXFGHFG
    'type' => Bearer
    'refresh' => xcdfghdfghdfghdrthdjfdffkdvznsvkzsdzhuhusfryzsdygb
    'expires_at' => 2018-12-07T07:28:45+0000
]

$token = Token::fromArray($array_token);

if($token->isExpiredAt(new \DateTimeImmutable('now')))
    {
                return $this->refreshToken($token);
    }
return $token;

function refreshToken(Token $token,$username = null){

        $baseUri = new Uri('https://target-sandbox.my.com/');
        $http = new GuzzleHttpTransport(new GuzzleClient());
        $credentials = new Credentials($this->client_id, $this->client_secret);

        $httpStack = HttpMiddlewareStackPrototype::newEmpty($http);
        $httpStack->push(new ResponseValidatingMiddleware());
        $access_token = $token->getAccessToken();
        $httpStack->push(new CallbackMiddleware(
            function (RequestInterface $req, HttpMiddlewareStack $stack, $context = null) use ($access_token) {
                $req = $req->withHeader('Authorization', sprintf('Bearer %s', $access_token));
                return $stack->request($req, $context);
            }
        ));

        $client = new Client(new RequestFactory($baseUri), $httpStack);

        $tokenOperator = new TokenOperator($client);
        $tokennew = $tokenOperator->refresh($credentials,$token, new Context($username));

        return $tokennew;
    }

```

получение токена для клиента происходит так же, только вместо refresh делаем

```
$token = $tokenOperator->acquire($credentials, new Context($username));

```

где $username - имя клиента, например 123123123@agency\_client

### Получение списка клиентов

[](#получение-списка-клиентов)

```
 $operator = new ClientOperator($client, $mapper);
 $operator->all();

```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~33 days

Recently: every ~16 days

Total

26

Last Release

2763d ago

Major Versions

0.5.4 → 1.0.02017-02-03

1.0.1 → 2.0.12018-10-01

2.0.3 → 3.0.12018-10-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f13149237849a48811ef73258c3b31cbf76c4058c3a6d29153959608d4e6194?d=identicon)[koma136](/maintainers/koma136)

---

Top Contributors

[![nikita2206](https://avatars.githubusercontent.com/u/1030688?v=4)](https://github.com/nikita2206 "nikita2206 (75 commits)")[![koma136](https://avatars.githubusercontent.com/u/15088755?v=4)](https://github.com/koma136 "koma136 (37 commits)")[![becksonq](https://avatars.githubusercontent.com/u/16672215?v=4)](https://github.com/becksonq "becksonq (26 commits)")[![coyl](https://avatars.githubusercontent.com/u/274452?v=4)](https://github.com/coyl "coyl (17 commits)")[![vmaslennikov-dsl](https://avatars.githubusercontent.com/u/18594158?v=4)](https://github.com/vmaslennikov-dsl "vmaslennikov-dsl (8 commits)")[![mem-memov](https://avatars.githubusercontent.com/u/1523512?v=4)](https://github.com/mem-memov "mem-memov (8 commits)")[![scarbo87](https://avatars.githubusercontent.com/u/2161963?v=4)](https://github.com/scarbo87 "scarbo87 (4 commits)")[![Tekill](https://avatars.githubusercontent.com/u/965890?v=4)](https://github.com/Tekill "Tekill (3 commits)")[![avolosyuk](https://avatars.githubusercontent.com/u/8543294?v=4)](https://github.com/avolosyuk "avolosyuk (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koma136-mytarget-sdk-php/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

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

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69734.4M144](/packages/algolia-algoliasearch-client-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.7k371.6k6](/packages/theodo-group-llphant)[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3845.9M26](/packages/gotenberg-gotenberg-php)

PHPackages © 2026

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