Difference between revisions of "Application Developers Example"
(→Загрузка ключа в движок) |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | ==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 Key: <tt>94d585bda4883a40d969d723adcaba36033e61d8</tt> | ||
* API Secret: <tt>b5dbd62b494664f5bfa9</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 | + | "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> | <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> | <nowiki>{"status": "error", "error": "error description"}</nowiki> | ||
− | * | + | *if NoADs option is not activated on the engine |
<nowiki>{"status": "ok", "services":[]}</nowiki> | <nowiki>{"status": "ok", "services":[]}</nowiki> | ||
− | * | + | *if NoADs option is activated on the engine |
<nowiki>{ | <nowiki>{ | ||
"status": "ok", | "status": "ok", | ||
Line 50: | Line 58: | ||
}</nowiki> | }</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/developer?method=createUserKey ↵ | <nowiki>https://api.acestream.net/developer?method=createUserKey ↵ | ||
&api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵ | &api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵ | ||
Line 73: | Line 82: | ||
&sign=fcf118b246892d80111de2661b79edb27ff48f08</nowiki> | &sign=fcf118b246892d80111de2661b79edb27ff48f08</nowiki> | ||
− | + | Response: | |
<nowiki>{ | <nowiki>{ | ||
"userKey":"84acee3a529bafaa65215af6f86d03fe38020b2d", | "userKey":"84acee3a529bafaa65215af6f86d03fe38020b2d", | ||
Line 87: | Line 96: | ||
}</nowiki> | }</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/ | + | <nowiki>https://api.acestream.net/developer?method=activateService ↵ |
&api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵ | &api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵ | ||
&api_version=1.0 ↵ | &api_version=1.0 ↵ | ||
Line 102: | Line 111: | ||
&sign=2f55622fb9c21af5b950c210774ea34247d1a073</nowiki> | &sign=2f55622fb9c21af5b950c210774ea34247d1a073</nowiki> | ||
− | + | Response: | |
<nowiki>{"validFrom":1401204680,"validTo":1403796680}</nowiki> | <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 | <nowiki>POST /webui/api/service?method=load_extension HTTP/1.1 | ||
Host: localhost | Host: localhost | ||
Line 122: | Line 131: | ||
L6OBnbrMrXSsjxahdQM2yFWRE\/gG91mEB6JNN0z99oswOiMghx0=</nowiki> | L6OBnbrMrXSsjxahdQM2yFWRE\/gG91mEB6JNN0z99oswOiMghx0=</nowiki> | ||
− | + | Response: | |
<nowiki>HTTP/1.0 200 OK | <nowiki>HTTP/1.0 200 OK | ||
Server: BaseHTTP/0.3 Python/2.7.2 | Server: BaseHTTP/0.3 Python/2.7.2 |
Latest revision as of 12:18, 6 September 2017
Contents
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 kjYX790gTytRaXV04IvC-xZH3A18sj5b1Tf3I-J5XVS1xsj-j0797KwxxLpBl26HPvWMm
- API Key: 94d585bda4883a40d969d723adcaba36033e61d8
- API Secret: b5dbd62b494664f5bfa9
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.
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:
>> 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
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 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:
http://localhost:6878/webui/api/service?method=get_services&product_key=kjYX790gTytRaXV04IvC
In the request you have to send a public part of the product key (kjYX790gTytRaXV04IvC) in parameter product_key.
Response options
- if an error was occured (this should not happen, so in this case, please, send us engine's logs)
{"status": "error", "error": "error description"}
- if NoADs option is not activated on the engine
{"status": "ok", "services":[]}
- if NoADs option is activated on the engine
{ "status": "ok", "services": [ { "id": "noAds", "name": "No ADs", "valid_from": 1376939146, "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" } ] }
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 id of each element (id of NoADs option - noAds).
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 createUserKey of API for resellers)
- activate NoADs option for this user key (method activateService of API for resellers)
- load user key to the engine (method 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 createUserKey of developer's API is used.
Request:
https://api.acestream.net/developer?method=createUserKey ↵ &api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵ &api_version=1.0 ↵ &product=kjYX790gTytRaXV04IvC ↵ &sign=fcf118b246892d80111de2661b79edb27ff48f08
Response:
{ "userKey":"84acee3a529bafaa65215af6f86d03fe38020b2d", "extension":"F5T6L+X\/TnhqoXP\/TyzlaaEmAT7uu97HHvJZ8u7 ↵ ShbGBf1w4OAgRhP7Hj0+DGzjK2AolsnfkMgOSFq4qYOlgQdWR3nRGJCq ↵ bX8QxqRC\/zbNu+3RerhylcdqvVEuAuWSuEQW0\/tgaqKaIVrfVSug\/ ↵ SVrBTLtXea\/4FLqXzz8lTYbv90p\/Nmw6jZcpaSaf4ISJQo9d+NTJ15 ↵ cz0emN+FtdABjIZNz91NVEWWyzMNl5iorzCWS8lYrdRQgT\/psdbf3N6 ↵ T2wfozL2b98yOkGH53eG4uc5wX+75xluvKwnKK32MJ7uDPZpDLHxTNc9 ↵ 2GCXKEloLFl+IyC91gghJpry6erUN3g9musH9CKvk4TZoZ+RTQINXlxr ↵ +IDklEnL6OBnbrMrXSsjxahdQM2yFWRE\/gG91mEB6JNN0z99oswOiMg ↵ hx0=" }
Activation
Method activateService of developer's API is used.
In the example NoADs option is activated for 1 month.
Request:
https://api.acestream.net/developer?method=activateService ↵ &api_key=94d585bda4883a40d969d723adcaba36033e61d8 ↵ &api_version=1.0 ↵ &product=kjYX790gTytRaXV04IvC ↵ &user_key=84acee3a529bafaa65215af6f86d03fe38020b2d ↵ &service=noAds ↵ &period=m1 ↵ &sign=2f55622fb9c21af5b950c210774ea34247d1a073
Response:
{"validFrom":1401204680,"validTo":1403796680}
Loading key to the engine
Method load_extension of service engine API is used.
Request:
POST /webui/api/service?method=load_extension HTTP/1.1 Host: localhost Content-Type: text/plain Content-Length: 437 F5T6L+X\/TnhqoXP\/TyzlaaEmAT7uu97HHvJZ8u7ShbGBf1w4OAgRhP7Hj0+DGz ↵ jK2AolsnfkMgOSFq4qYOlgQdWR3nRGJCqbX8QxqRC\/zbNu+3RerhylcdqvVEuAu ↵ WSuEQW0\/tgaqKaIVrfVSug\/SVrBTLtXea\/4FLqXzz8lTYbv90p\/Nmw6jZcpa ↵ Saf4ISJQo9d+NTJ15cz0emN+FtdABjIZNz91NVEWWyzMNl5iorzCWS8lYrdRQgT\ ↵ /psdbf3N6T2wfozL2b98yOkGH53eG4uc5wX+75xluvKwnKK32MJ7uDPZpDLHxTNc ↵ 92GCXKEloLFl+IyC91gghJpry6erUN3g9musH9CKvk4TZoZ+RTQINXlxr+IDklEn ↵ L6OBnbrMrXSsjxahdQM2yFWRE\/gG91mEB6JNN0z99oswOiMghx0=
Response:
HTTP/1.0 200 OK Server: BaseHTTP/0.3 Python/2.7.2 Date: Tue, 27 May 2014 15:46:22 GMT Content-Type: application/json Content-Length: 16 {"status": "ok"}