Z
Z
zzmaster2017-10-17 10:37:04
Yandex
zzmaster, 2017-10-17 10:37:04

Yandex direct v4 - how to get AccountManagement data?

It is necessary to get data from AccountManagement via API v4 (yes, I know, she is dying ..) using the Get method, which is described here
https://tech.yandex.ru/direct/doc/dg-v4/live/Accou...
actually interested in balance.
I send a script (php file_get_contents via stream_context_create, which is not important) requests to
https://api.direct.yandex.ru/v4/json
https://api.direct.yandex.ru/live/v4/json

[options] => Array
        (
            [method] => POST
            [header] => Content-Type: application/json; charset=utf-8
Content-length: 130

            [content] => {"method":"AccountManagement","param":{"Action":"Get","SelectionCriteria":{"logins":["AAAAAAAAAAAAAAAAAAAAAAAAA"]}}}
        )

getting headers
[headers] => Array
        (
            [0] => HTTP/1.1 200 OK
            [1] => Server: nginx
            [2] => Date: Tue, 17 Oct 2017 07:24:02 GMT
            [3] => Content-Type: application/json; charset=utf-8
            [4] => Connection: close
            [5] => RequestId: 7327377433625588421
            [6] => X-Frame-Options: SAMEORIGIN
            [7] => X-Content-Type-Options: nosniff
            [8] => X-XSS-Protection: 1; mode=block
            [9] => Content-Security-Policy: default-src 'none'
        )

and the actual answer
{"error_str":"Authorization error","error_detail":"","error_code":53}

I have a suspicion that before this request, you need to get an OAuth token, as described here
https://tech.yandex.ru/direct/doc/dg-v4/concepts/a...
But then what - the user should receive this the token itself, add it to the URL, like
https://api.direct.yandex.ru/v4/json?token=lafafa
and then execute requests? And then queries from cron will stop working as soon as the token expires? (By the way, how long does it last?)
All this is for version v4, let me remind you. Help please!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zzmaster, 2017-10-18
@zzmaster

It turned out that the token that I have is the Oauth authorization token and it must be passed to json:

[content] => {"method":"AccountManagement", "token": "AAAAAAAAAAAAAAA"...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question