117
edits
Changes
no edit summary
==ОбщееCommon описаниеdescription of API==
This API allows application developers to work with [[User_key|user keys]] in Ace Stream system. API provides methods for creating user keys and activating different options for the keys.
==Requests format==
API requests are sent via HTTP-GET method to the following addresses:
* тестовыйtest режимmode: <tt><nowiki>https://api-sandbox.acestream.net/developer</nowiki></tt>
* боевойwork режимmode: <tt><nowiki>https://api.acestream.net/developer</nowiki></tt>
Responses for these requests comes in JSON format.
If during query processing an error was occurred, the following kind of response will be sent:
<tt><nowiki>{"error":"error descrtiption"}</nowiki></tt>
Responses to successfully processed requests depend on a method being called.
===Required common parameters for all requests===
* '''method''' - вызываемый методcalled API method
* '''api_key''' - ключAPI клиентаclient key API
* '''api_version''' - поддерживаемая версияsupported API version (текущаяcurrent версияversion: 1.0)
* '''product''' - публичнаяpublic частьpart of [[Product_key/en|ключаproduct продуктаkey]]
* '''sign''' - цифроваяrequest's подписьdigital signature запроса
===Algorithm for generating a digital signature===
* array of strings like "parameter_name=parameter_value" is created
* the resulting array is sorted
* elements of the sorted array are combined in a string with a separator "#"
* private key of API client is added to the resulting string
* signature is sha1-hash of the resulting string (in hexadecimal representation, 40 characters, lowercase)
PHP code:
<tt><nowiki>function makeSignature(array $params, $apiSecret)
{
}</nowiki></tt>
==Методы API methods==
===getServiceCost===
Get the cost of a service
parameters:
* '''service''' (''string'') - идентификаторservice ID опции
* '''period''' (''string'') - идентификаторperiod ID периода
fields in response:
* '''cost''' (''decimal'') - стоимостьthe опцииcost наof указанныйthe периодservice вfor a specified period in EUR
request example:
<nowiki>https://api.acestream.net/developer?method=getServiceCost ↵
&api_version=1.0 ↵
&api_key=be6f66e0848528139583b567fb222215444fc8ac ↵
&app=9_50gh753t6uscog88800kcksw04s0o0wccscco8kgsogwkocwgw ↵
&service=noAds ↵
&period=m1 ↵
&sign=45c84ceffd3ec443586e8f4666b28abde8400768</nowiki>
response:
<nowiki>{"cost":1}</nowiki>
===activateService===
Activate service for user
As a result of successful activation, funds will be charged from developer's balance.
parameters:
* '''user_key''' (''string'') - ключuser key пользователя
* '''service''' (''string'') - идентификаторservice ID опции
* '''period''' (''string'') - идентификаторperiod ID периода
fields in response:
* '''validFrom''' (''unix timestamp'') - сfrom какогоwhat времениtime опцияservice is active активна
* '''validTo''' (''unix timestamp'') - доtill какогоwhat времениtime опцияservice will be active активна
request example:
<nowiki>https://api.acestream.net/developer?method=activateService ↵
&api_version=1.0 ↵
&api_key=be6f66e0848528139583b567fb222215444fc8ac ↵
&app=9_50gh753t6uscog88800kcksw04s0o0wccscco8kgsogwkocwgw ↵
&user_key=a455865e5800fd7efab75f2b4852fc2497f9fc39 ↵
&service=noAds ↵
&sign=c4df772a4a41ad7bbb4d7d07e46cad5e3622c59e</nowiki>
response (successful activation):
<nowiki>{"validFrom":1376048972,"validTo":1378640972}</nowiki>
response (there are not enough funds on developer's balance to activate the service):
<nowiki>{"error":"not enough credits"}</nowiki>
===getUserKeyInfo===
Get information about user key
parameters:
* '''user_key''' (''string'') - ключuser key пользователя
fields in response:
* '''services''' (''array'') - array of services, bound to this user key. Each service ia described with the following fields
** '''id''' (''string'') - идентификаторservice ID опции
** '''validFrom''' (''unix timestamp'') - сfrom какогоwhat времениtime опцияservice is active активна
** '''validTo''' (''unix timestamp'') - доtill какогоwhat времениtime опцияservice will be active активна
** '''enabled''' (''boolean'') - активнаis лиservice опцияactive вat данныйthis moment момент
request example:
<nowiki>https://api.acestream.net/developer?method=getUserKeyInfo ↵
&api_version=1.0 ↵
&api_key=be6f66e0848528139583b567fb222215444fc8ac ↵
&app=9_50gh753t6uscog88800kcksw04s0o0wccscco8kgsogwkocwgw ↵
&user_key=8fb311be3836b04f61817dbf8a23c05739ebb13e ↵
&sign=5e0fc46d908e5f224ce9fce9f6a83dd6b3502cc0</nowiki>
response (no services):
<tt>{"services":[]}</tt>
response (there are services):
<nowiki>{"services": [
{"id": "noAds", "validFrom": 1374673235, "validTo": 1445089235, "enabled": true},
===createUserKey===
Create a new user key
Effect of user key applies only to developer's product, specified in parameter <tt>product</tt>.
fields in response:
* '''userKey''' (''string'') - созданныйcreated ключuser key пользователя
* '''extension''' (''string'') - content of extension file which is used for the following loading to the engine
request example:
<nowiki>https://api.acestream.net/developer?method=createUserKey ↵
&api_key=cd3119af58cfa8833ba105a4fd4eb791395b921c ↵
&api_version=1.0 ↵
&app=3_250o55jdisu88skggogg4g4w4wc8wgskss4gkgkkk40k0gcsw8 ↵
&sign=99982a11708ef4a80e12f1ca845d314340db8869</nowiki>
response:
<tt>{
"userKey": "c7456d962209ce22a8edd0c788940a15792bc575",
}</tt>
==Service ID==
* '''noAds''' - опцияservice "No ADs" (отключение рекламыdisable Ace Stream ads)
* '''premium''' - опцияservice "Premium Streams" (доступaccess кto премиум-контентуpremium content)
* '''premium1device''' - премиумservice на"Premium одноStreams" устройствоfor one device
==Period ID==
* '''m1''' - 30 днейdays
* '''y1''' - 365 днейdays