117
edits
Changes
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 Stream engine.
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 NoADs option 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"
Example of such an error according to [[Engine_API/en|Engine API]]:
<nowiki>>> START PID 94c2fd8fb9bc8f2fc71a2cbe9d4b866f227a0209 0
<< STATE 1
<< 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==
<nowiki>http://localhost:6878/webui/api/service?method=get_services&product_key=kjYX790gTytRaXV04IvC</nowiki>
'''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 NoADs option is not activated on the engine
<nowiki>{"status": "ok", "services":[]}</nowiki>
*if NoADs option is activated on the engine
<nowiki>{
"status": "ok",
}</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 APIservice движка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/developer?method=createUserKey ↵
&api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵
&sign=fcf118b246892d80111de2661b79edb27ff48f08</nowiki>
Response:
<nowiki>{
"userKey":"84acee3a529bafaa65215af6f86d03fe38020b2d",
}</nowiki>
==Activation==
In the example NoADs option is activated for 1 month.
Request:
<nowiki>https://api.acestream.net/developer?method=activateService ↵
&api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵
&sign=2f55622fb9c21af5b950c210774ea34247d1a073</nowiki>
Response:
<nowiki>{"validFrom":1401204680,"validTo":1403796680}</nowiki>
==Loading key to the engine==
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