Changes

Jump to: navigation, search

Application Developers Example

376 bytes removed, 13:18, 6 September 2017
no edit summary
==Общая информацияCommon information==Данный пример пошагово описывает все необходимые шаги для настройки работы стороннего приложения с движком This example is a step-by-step description of all necessary steps to set up work of a third-party application with Ace Streamengine.
Во всех запросах для примера будут использоваться такие переменныеAll requests for the example will use the following variables:* ключ продукта product key <tt>kjYX790gTytRaXV04IvC-xZH3A18sj5b1Tf3I-J5XVS1xsj-j0797KwxxLpBl26HPvWMm</tt>
* API Key: <tt>94d585bda4883a40d969d723adcaba36033e61d8</tt>
* API Secret: <tt>b5dbd62b494664f5bfa9</tt>
Эти данные приведены исключительно для наглядности примераThese data are presented only to illustrate the example, в will not work in a "боевомreal life" режиме они работать не будут.
==Регистрация разработчика и получение ключа продуктаDeveloper's registration and getting a product key==Для начала Вам необходимо зарегистрироваться в системе To start you have to register in Ace Stream как разработчик приложений, после чего Вы сможете зарегистрировать свое приложение и получить для него ключ продуктаsystem as application developer. Как это сделать, описано в разделе After that you will be able to register your application and get the product key for it. How to do this is described in a section [[Developers/en|РазработчикиDevelopers]].
==Работа с движкомWorking with the engine==По умолчанию работать с Вашим приложением будет только движок, для которого активирована опция By default only the engine with activated NoADsoption will work with your application.
Если эта опция не активированаIf this option is not activated, то на любую попытку воспроизвести что-либо движок будет возвращать ошибку с таким текстомthe engine will return an error with the following text to any attempt to play anything:"No ADs option must be activated to use this product"
Соответственно, для начала работы Вашему приложению необходимо проверить, активирована ли опция NoADs на движке.Example of such an error according to [[Engine_API/en|Engine API]]: <nowiki>>> START PID 94c2fd8fb9bc8f2fc71a2cbe9d4b866f227a0209 0<< STATE 1<< STATUS main:starting<< STATE 0<< STATUS main:idle<< STATUS main:err;0;No ADs option must be activated to use this product</nowiki>
So, to start working your application has to check whether NoADs option is activated on the engine. ==Проверка активации опции Checking activation of NoADs на движкеoption on the engine==Метод Method [[Engine_Service_API/en#get_services|get_services]] сервисного of service engine API движка позволяет узнать, какие опции активированы на движкеallows to find out what options are activated on the engine. Для этого нужно отправить To do this you have to send HTTP GET запрос на движокrequest to the engine:
<nowiki>http://localhost:6878/webui/api/service?method=get_services&product_key=kjYX790gTytRaXV04IvC</nowiki>
В запросе нужно передать публичную часть ключа продукта In the request you have to send a public part of the product key (kjYX790gTytRaXV04IvC) в параметре in parameter <tt>product_key</tt>.
'''Варианты ответовResponse options'''
*если возникла ошибка if an error was occured (нужно выслать нам логи движкаthis should not happen, so in this case, please, send us engine's logs) <nowiki>{"status": "error", "error": "error description"}</nowiki>
*если на движке не активирована опция if NoADsoption is not activated on the engine <nowiki>{“status”"status": “ok”"ok",“services”"services":[]}</nowiki>
*если на движке активирована опция if NoADsoption is activated on the engine
<nowiki>{
“status”"status": “ok”"ok",“services”"services":
[
{
"valid_to": 1411671946,
"trial": false,
"description": "\u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u043a\u043b\u0430\u043c\u044b Ace Stream"
}
]
}</nowiki>
В возвращаемом списке могут быть и другие опции, кроме There may be other options except NoADsin the returned list. Для тогоTo find out, чтобы узнатьwhether a specific option is activated, активирована ли конкретная опция, нужно пройтись по списку и проверять поле you have to go through the list and check field <tt>id</tt> of each element (<tt>id</tt> каждого элементаof NoADs option - <tt>noAds</tt>). If NoADs option is not activated, your application can activate it. To do this you have to follow these steps:* create a new user key (method [[Reseller_API/en#createUserKey|createUserKey]] of API for resellers)* activate NoADs option for this user key (method [[Reseller_API/en#activateService|activateService]] of API for resellers)* load user key to the engine (method [[Engine_Service_API/en#load_extension|extension]] of service engine API) Task of user key is to identify user of your application in Ace Stream system without the need for the user to register in our system,. If you are able to bind user key, created using developer API, with a specific user of your application, we recommend you to do that. In this case, if necessary, for example, re-activate an additional option for the user you will not need to create a new user key. It will be enough to activate the option for existing one
Если опция NoADs не активирована, ее нужно активироватьMore detailed steps about creating a new user key and activation are below. Для этого нужно выполнить такие шаги:* создать новый ключ пользователя (метод [[Reseller_API#createUserKey|createUserKey]] API для реселлеров)* активировать опцию NoADs для этого ключа пользователя (метод [[Reseller_API#activateService|activateService]] API для реселлеров)* загрузить ключ пользователя в движок (метод [[Engine_Service_API#load_extension|extension]] сервисного API движка)
Ниже эти шаги описаны более подробно==Creating user key==Method [[Developer_API/en#createUserKey|createUserKey ]] of developer's API is used.
==Создание ключа пользователя==ЗапросRequest: <nowiki>https://api.acestream.net/resellerdeveloper?method=createUserKey &crarr;
&api_key=94d585bda4883a40d969d723adcaba36033e61d8 &crarr;
&api_version=1.0 &crarr;
&sign=fcf118b246892d80111de2661b79edb27ff48f08</nowiki>
ОтветResponse:
<nowiki>{
"userKey":"84acee3a529bafaa65215af6f86d03fe38020b2d",
}</nowiki>
==АктивацияActivation==ЗапросMethod [[Developer_API/en#activateService|activateService]] of developer's API is used. In the example NoADs option is activated for 1 month. Request: <nowiki>https://api.acestream.net/resellerdeveloper?service=noAds &crarr; &period=m1 &crarr; &user_key=84acee3a529bafaa65215af6f86d03fe38020b2d &crarr; &method=activateService &crarr;
&api_key=94d585bda4883a40d969d723adcaba36033e61d8 &crarr;
&api_version=1.0 &crarr;
&product=kjYX790gTytRaXV04IvC &crarr;
&user_key=84acee3a529bafaa65215af6f86d03fe38020b2d &crarr;
&service=noAds &crarr;
&period=m1 &crarr;
&sign=2f55622fb9c21af5b950c210774ea34247d1a073</nowiki>
ОтветResponse:
<nowiki>{"validFrom":1401204680,"validTo":1403796680}</nowiki>
==Загрузка ключа в движокLoading key to the engine==ЗапросMethod [[Engine_Service_API/en#load_extension|load_extension]] of service engine API is used. Request:
<nowiki>POST /webui/api/service?method=load_extension HTTP/1.1
Host: localhost
L6OBnbrMrXSsjxahdQM2yFWRE\/gG91mEB6JNN0z99oswOiMghx0=</nowiki>
ОтветResponse:
<nowiki>HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.7.2

Navigation menu