Changes

Jump to: navigation, search

Application Developers Example

326 bytes added, 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>
==Регистрация разработчика и получение ключа продукта==Для начала Вам необходимо зарегистрироваться в системе Ace Stream как разработчик приложенийThese data are presented only to illustrate the example, после чего Вы сможете зарегистрировать свое приложение и получить для него ключ продукта. Как это сделать, описано в разделе [[Developers|Разработчики]]will not work in a "real life".
==Работа с движкомDeveloper's registration and getting a product key==Работать с Вашим приложением будет только движок, для которого активирована опция NoADsTo 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==No ADs By default only the engine with activated NoADs option must be activated to use this productwill work with your application.
Для начала Вашему приложению необходимо проверитьIf this option is not activated, активирована ли опция NoADs на движке.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"
Для этого следует использовать метод 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 NoADs не активированаin 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.  More detailed steps about creating a new user key and activation are below.
Ниже эти шаги описаны более подробно==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