| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- /**
- * test.php
- *
- * contains examples about how to use
- * class methods for Sf_Admin
- *
- * @author André Genrich <andre.genrich@thurdata.ch>
- * @version 1
- * @copyright Copyright (c) Thurdata GmbH 2020
- * @license GPL
- * @name test.php
- */
- /////////////
- // Require //
- /////////////
- require_once('config.php');
- require_once('cwp7/Admin.php');
- //////////
- // Args //
- //////////
- if(PHP_SAPI != 'cli')
- $args = $_GET;
- else
- $args = parse_args($argv);
- if(isset($args['action']))
- {
- $action = $args['action'];
- }
- else
- {
- echo 'No action, exiting' . PHP_EOL;
- exit (-1);
- }
- function parse_args($argv){
- array_shift($argv);
- $out = array();
- foreach ($argv as $arg){
- if (substr($arg,0,2) == '--'){
- $eqPos = strpos($arg,'=');
- if ($eqPos === false){
- $key = substr($arg,2);
- $out[$key] = isset($out[$key]) ? $out[$key] : true;
- } else {
- $key = substr($arg,2,$eqPos-2);
- $out[$key] = substr($arg,$eqPos+1);
- }
- } else if (substr($arg,0,1) == '-'){
- if (substr($arg,2,1) == '='){
- $key = substr($arg,1,1);
- $out[$key] = substr($arg,3);
- } else {
- $chars = str_split(substr($arg,1));
- foreach ($chars as $char){
- $key = $char;
- $out[$key] = isset($out[$key]) ? $out[$key] : true;
- }
- }
- } else {
- $out[] = $arg;
- }
- }
- return $out;
- }
- /////////////////
- // Constructor //
- /////////////////
- $cwp7 = new cwp7_Admin($cwp7URL, $cwp7Token);
- $r = $cwp7->constructorSuccess();
- if(isset($r['error_msg'])) {
- echo 'Error : cannot construct :-(' . PHP_EOL;
- print_r($r);
- exit();
- }
- /////////////
- // Actions //
- /////////////
- // Get All Accounts
- if($action == 'gaa')
- {
- $r = $cwp7->getAllAccounts();
- print_r($r);
- }
|