-
Notifications
You must be signed in to change notification settings - Fork 0
/
HowTo.php
67 lines (58 loc) · 1.71 KB
/
HowTo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
//load System
require_once('system/system.php');
$system = new System;
##### CONFIG ####
//get config
$config = $system->registry->get('config');
//load other config file
$config->load('example');
//set config value
$config->set('soap_user','demo');
//small code
$system->registry->get('config')->set('soap_url','www.example.com');
#### REQUEST ####
$system->api->request('FunctionName','Parameter','Auth');
#### EXAMPLE ####
//TestSayHello
$params = array(
'firstname' => 'John',
'lastname' => 'Doe'
);
$result = $system->api->request('TestSayHello',$params);
echo $result['response']->version;
//Change the server between requests
//You do not need to load new config or overwrite the values in the config
//Server 1
$auth_server_1 = array(
'soap_user' => 'admin1',
'soap_pass' => 'Demo',
'soap_url' => 'https://example.com:8443/liveconfig/soap'
);
$auth_server_2 = array(
'soap_user' => 'admin2',
'soap_pass' => 'Demo',
'soap_url' => 'https://example2.com:8443/liveconfig/soap'
);
$params = array(
'firstname' => 'John',
'lastname' => 'Doe'
);
//Request server 1
$system->api->request('TestSayHello',$params,$auth_server_1);
//Requst server 2
$system->api->request('TestSayHello',$params,$auth_server_2);
#### RESPONSE ####
$result = $system->api->request('TestSayHello',$params);
//!isset($result['status']) => You found a bug
//!$result['status'] => Error or Exeption
//If the status is true, it only means that the request has been executed successfully.
//Nevertheless you need to check the return of the server for serverside errors (missing parameter).
if(!isset($result['status']) OR !$result['status'])
{
echo 'ERROR';
}
else
{
$api_response = $result['response'];
}