SHARE
TWEET

xtrream codes

enricoluigi Sep 22nd, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. Creating New Line
  4.  
  5. To create a New line, we will call the following URL.
  6.  
  7. http://dns:port/api.php?action=user&sub=create
  8.  
  9. The above URL, accepts the POST action, and to create a new line we will have to specify some arguments in an array called user_data
  10.  
  11. Example Code:
  12.  
  13. PHP:
  14.  
  15. <?php
  16.  
  17. $panel_url = 'http://DNS:PORT/';
  18. $username = 'test_username';
  19. $password = 'test_password';
  20. $max_connections = 1;
  21. $reseller = 1;
  22. $bouquet_ids = array(
  23.     1,
  24.     2,
  25.     3 );
  26. $expire_date = strtotime( "+1 month" );
  27.  
  28. ###############################################################################
  29. $post_data = array( 'user_data' => array(
  30.         'username' => $username,
  31.         'password' => $password,
  32.         'max_connections' => $max_connections,
  33.         'is_restreamer' => $reseller,
  34.         'exp_date' => $expire_date,
  35.         'bouquet' => json_encode( $bouquet_ids ) ) );
  36.  
  37. $opts = array( 'http' => array(
  38.         'method' => 'POST',
  39.         'header' => 'Content-type: application/x-www-form-urlencoded',
  40.         'content' => http_build_query( $post_data ) ) );
  41.  
  42. $context = stream_context_create( $opts );
  43. $api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=create", false, $context ) );
  44.  
  45. ?>
  46.  
  47. If you leave the username and/or password elements empty, the system will generate random characters for these 2 fields. In addition, leaving any field empty, api will use the default value for this field according to SQL Database. So theoretically, you can make a line with just Calling the Above URL, without any parameter, however the created user, wont have any bouquets inside.
  48.  
  49. You can call any other element that is in the database like
  50.  
  51.     member_id
  52.     admin_enabled
  53.     enabled
  54.     allowed_ips
  55.     allowed_ua
  56.     force_server_id
  57.     is_isplock
  58.     admin_notes
  59.     and so on...
  60.  
  61. If you want to set the allowed_ips/allowed_ua since this is a JSON Encoded format you can do it like bouquet in the above Code.
  62.  
  63. The API will return a simple json encoded string that upon decoding will contain the element result which returns true/false.
  64.  
  65. Example(API Success)
  66.  
  67. JSON:
  68.  
  69. {"result":true,"created_id":14838,"username":"d4PSc5uCqF","password":"2ZiuRRZk4b"}
  70.  
  71. The API returned as the username/password of the NEW line, as well as the ID so we can use it wherever we want.
  72.  
  73. Example(API Failed)
  74.  
  75. JSON:
  76.  
  77. {"result":false,"error":"EXISTS"}
  78. {"result":false,"error":"PARAMETER ERROR"}
  79.  
  80.     EXISTS
  81.     The Username you specified already exists in the database
  82.     PARAMETER ERROR
  83.     You wrote invalid characters in your user_data array
  84.  
  85.  
  86. Editing Line
  87.  
  88. To procedure to edit a line is very similar to the above. The URL we will call this time is
  89.  
  90. http://dns:port/api.php?action=user&sub=edit
  91.  
  92. REQUIRED PARAMETERS
  93.  
  94.     username
  95.     password
  96.  
  97. OPTIONAL PARAMETERS
  98.  
  99.     user_data array
  100.  
  101. For example if we want to Edit the Expire Date, make the line restreamer and adjusting the max connections to 10 we will do it like this:
  102.  
  103. PHP:
  104.  
  105. <?php
  106.  
  107. $panel_url = 'http://DNS:PORT/';
  108. $username = 'test_username';
  109. $password = 'test_password';
  110. $max_connections = 10;
  111. $reseller = 1;
  112. $expire_date = strtotime( "+1 month" ); //from the time now, not from line's expire date.
  113.  
  114. ###############################################################################
  115. $post_data = array(
  116.     'username' => $username,
  117.     'password' => $password,
  118.     'user_data' => array(
  119.         'max_connections' => $max_connections,
  120.         'is_restreamer' => $reseller,
  121.         'exp_date' => $expire_date ) );
  122.  
  123. $opts = array( 'http' => array(
  124.         'method' => 'POST',
  125.         'header' => 'Content-type: application/x-www-form-urlencoded',
  126.         'content' => http_build_query( $post_data ) ) );
  127.  
  128. $context = stream_context_create( $opts );
  129. $api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=edit", false, $context ) );
  130.  
  131. ?>
  132.  
  133. In the above example, we will edit the max_connections, is_restreamer and exp_date for our line with username test_username, and password test_password that already exists in our database.
  134.  
  135. Example(API Success)
  136.  
  137. JSON:
  138.  
  139. {"result":true}
  140.  
  141. Example(API Failed)
  142.  
  143. JSON:
  144.  
  145. {"result":false,"error":"NOT EXISTS"}
  146. {"result":false,"error":"PARAMETER ERROR"}
  147. {"result":false,"error":"PARAMETER ERROR (user\/pass)"}
  148.  
  149.     NOT EXISTS
  150.     The Username / Password you specified are not exists in the database
  151.     PARAMETER ERROR
  152.     You wrote invalid characters in your user_data array
  153.     PARAMETER ERROR (user/pass)
  154.     The Username OR/AND Password elements are missing
  155.  
  156. View Line Information
  157.  
  158. With this API call, we will get all the information available about our line including the active connections.
  159.  
  160. The URL we will call this time is
  161.  
  162. http://dns:port/api.php?action=user&sub=info
  163.  
  164. REQUIRED PARAMETERS
  165.  
  166.     username
  167.     password
  168.  
  169. It will return a JSON Encoded string, with all information that you might want.
  170.  
  171. Example Code:
  172.  
  173. PHP:
  174.  
  175. $panel_url = 'http://DNS:PORT/';
  176. $username = "username";
  177. $password = "passwrd";
  178.  
  179.  
  180. ###############################################################################
  181. $post_data = array( 'username' => $username, 'password' => $password );
  182. $opts = array( 'http' => array(
  183.         'method' => 'POST',
  184.         'header' => 'Content-type: application/x-www-form-urlencoded',
  185.         'content' => http_build_query( $post_data ) ) );
  186.  
  187. $context = stream_context_create( $opts );
  188. $api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=info", false, $context ), true );
  189.  
  190. if ( $api_result['result'] )
  191. {
  192.     echo "Active Connections (Now): " . $api_result['user_info']['active_cons'];
  193.     echo "\nCurrent Expire Date: " . (( empty( $api_result['user_info']['exp_date'] ) ) ? 'Unlimited' : strtotime( $api_result['user_info']['exp_date'] ));
  194.     echo "\nMax Connections: " . $api_result['user_info']['max_connections'];
  195.     echo "\nAvailable Channel IDs: " . implode( ',', $api_result['user_info']['channel_ids'] );
  196. }
  197. else
  198.     echo 'FAILED';
  199.  
  200. Create/Edit & View Information on MAG Devices
  201.  
  202. The procedure is almost the same as creating/editing & view info on a user line. The only difference is that instead of calling the user action, we will the stb action. Of course instead of username/password we will just have the mac parameter.
  203.  
  204.  
  205. Example API Call To Create New MAG
  206.  
  207. http://dns:port/api.php?action=stb&sub=create
  208.  
  209. REQUIRED PARAMETERS
  210.  
  211.     user_data[mac]
  212.  
  213. PHP:
  214.  
  215. <?php
  216.  
  217. $panel_url = 'http://DNS:PORT/';
  218. $mac = '00:1A:79:79:79:79';
  219. $bouquet_ids = array(
  220.     1,
  221.     2,
  222.     3 );
  223. $expire_date = strtotime( "+1 month" );
  224.  
  225. ###############################################################################
  226. $post_data = array( 'user_data' => array(
  227.         'mac' => $mac,
  228.         'exp_date' => $expire_date,
  229.         'bouquet' => json_encode( $bouquet_ids ) ) );
  230.  
  231. $opts = array( 'http' => array(
  232.         'method' => 'POST',
  233.         'header' => 'Content-type: application/x-www-form-urlencoded',
  234.         'content' => http_build_query( $post_data ) ) );
  235.  
  236. $context = stream_context_create( $opts );
  237. $api_result = json_decode( file_get_contents( $panel_url . "api.php?action=stb&sub=create", false, $context ) );
  238. print_r($api_result);
  239.  
  240. ?>
  241.  
  242. Example(API Success)
  243.  
  244. JSON:
  245.  
  246. {"result":true}
  247.  
  248. Example(API Failed)
  249.  
  250. JSON:
  251.  
  252. {"result":false,"error":"NOT EXISTS"}
  253. {"result":false,"error":"PARAMETER ERROR"}
  254. {"result":false,"error":"PARAMETER ERROR (mac)"}
  255.  
  256.     EXISTS
  257.     The MAC already exists in the database
  258.     PARAMETER ERROR
  259.     You wrote invalid characters in your user_data array
  260.     PARAMETER ERROR (mac)
  261.     The MAC Parameter was missing
  262.  
  263.  
  264. Example API Call To Edit a MAG Device
  265.  
  266. http://dns:port/api.php?action=stb&sub=edit
  267.  
  268. REQUIRED PARAMETERS
  269.  
  270.     mac
  271.  
  272. PHP:
  273.  
  274. <?php
  275.  
  276. $panel_url = 'http://DNS:PORT/';
  277. $mac = '00:1A:79:79:79:79';
  278. $bouquet_ids = array(
  279.     1,
  280.     2,
  281.     3 );
  282. $expire_date = strtotime( "+1 month" );
  283.  
  284. ###############################################################################
  285. $post_data = array( 'mac' => $mac, 'user_data' => array( 'exp_date' => $expire_date, 'bouquet' => json_encode( $bouquet_ids ) ) );
  286.  
  287. $opts = array( 'http' => array(
  288.         'method' => 'POST',
  289.         'header' => 'Content-type: application/x-www-form-urlencoded',
  290.         'content' => http_build_query( $post_data ) ) );
  291.  
  292. $context = stream_context_create( $opts );
  293. $api_result = json_decode( file_get_contents( $panel_url . "api.php?action=stb&sub=edit", false, $context ) );
  294. ?>
  295.  
  296. Example(API Success)
  297.  
  298. JSON:
  299.  
  300. {"result":true}
  301.  
  302. Example(API Failed)
  303.  
  304. JSON:
  305.  
  306. {"result":false}
  307. {"result":false,"error":"PARAMETER ERROR"}
  308. {"result":false,"error":"PARAMETER ERROR (mac)"}
  309.  
  310.     no error
  311.     The updated information, are the same as in the database, so no action taken.
  312.     PARAMETER ERROR
  313.     You wrote invalid characters in your user_data array
  314.     PARAMETER ERROR (mac)
  315.     The MAC Parameter was missing
  316.  
  317.  
  318. View Information MAG Device
  319.  
  320. http://dns:port/api.php?action=stb&sub=info
  321.  
  322. REQUIRED PARAMETERS
  323.  
  324.     mac
  325.  
  326. It will return a JSON Encoded string, with all information that you might want.
  327.  
  328. Example Code:
  329.  
  330. PHP:
  331.  
  332. <?php
  333.  
  334. $panel_url = 'http://DNS:PORT/';
  335. $mac = '00:1A:79:79:79:79';
  336.  
  337.  
  338. ###############################################################################
  339. $post_data = array( 'mac' => $mac);
  340. $opts = array( 'http' => array(
  341.         'method' => 'POST',
  342.         'header' => 'Content-type: application/x-www-form-urlencoded',
  343.         'content' => http_build_query( $post_data ) ) );
  344.  
  345. $context = stream_context_create( $opts );
  346. $api_result = json_decode( file_get_contents( $panel_url . "api.php?action=stb&sub=info", false, $context ), true );
  347.  
  348.  
  349. if ( $api_result['result'] )
  350. {
  351.     echo "Active Connections (Now): " . $api_result['user_info']['active_cons'];
  352.     echo "\nCurrent Expire Date: " . ( ( empty( $api_result['user_info']['exp_date'] ) ) ? 'Unlimited' : strtotime( $api_result['user_info']['exp_date'] ) );
  353.     echo "\nMax Connections: " . $api_result['user_info']['max_connections'];
  354.     echo "\nAvailable Channel IDs: " . implode( ',', $api_result['user_info']['channel_ids'] );
  355. }
  356. else
  357.     echo 'FAILED';
  358.  
  359. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top