| 1 | = Dodanie wpisów do rejestru = |
| 2 | |
| 3 | |
| 4 | ''' Definicja parametrów: ''' |
| 5 | {{{ |
| 6 | #!php |
| 7 | <?php |
| 8 | |
| 9 | /** |
| 10 | * Dodaje jeden i więcej wpisów do rejestru |
| 11 | * |
| 12 | * @param integer Id rejestru |
| 13 | * @param string json |
| 14 | * |
| 15 | * @access public |
| 16 | * @return string json |
| 17 | */ |
| 18 | public function addRegisterEntries($register_id, $data) { |
| 19 | |
| 20 | ?> |
| 21 | }}} |
| 22 | |
| 23 | ''' Przykłady wywołań: ''' |
| 24 | {{{ |
| 25 | #!php |
| 26 | |
| 27 | // Plik MyService.php umieszczony w apps/edokumenty. |
| 28 | // MyService.php |
| 29 | <?php |
| 30 | |
| 31 | define('EDOK_API_LOGIN', 'developer'); |
| 32 | define('EDOK_API_PASSWORD', 'developer'); |
| 33 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| 34 | |
| 35 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| 36 | |
| 37 | $options = array( |
| 38 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| 39 | "uri" => "eDokumentyAPI", |
| 40 | 'encoding'=>'UTF-8' |
| 41 | ); |
| 42 | |
| 43 | $client = new EDokApiClient(NULL, $options); |
| 44 | $client->setUser(EDOK_API_LOGIN); |
| 45 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| 46 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| 47 | $client->__setSoapHeaders($header); |
| 48 | |
| 49 | try { |
| 50 | $data = array( |
| 51 | 'name__' => 'oskar_reg_2', |
| 52 | ); |
| 53 | $reg_data = $client->getRegister($data); |
| 54 | var_dump($reg_data); |
| 55 | |
| 56 | } catch(SoapFault $fault) { |
| 57 | |
| 58 | var_dump($fault); |
| 59 | |
| 60 | if ($fault->faultcode < 100) { |
| 61 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | try { |
| 66 | $data = array( |
| 67 | 'name__' => 'oskar_reg_2', |
| 68 | ); |
| 69 | $max_date = $client->getMaxDateForRegister($data); |
| 70 | var_dump($max_date); |
| 71 | |
| 72 | } catch(SoapFault $fault) { |
| 73 | |
| 74 | var_dump($fault); |
| 75 | |
| 76 | if ($fault->faultcode < 100) { |
| 77 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | try { |
| 82 | $data = array(); |
| 83 | for ($i = 100; $i--;) { |
| 84 | $data[] = array( |
| 85 | 'dscrpt' => 'r '.date('d H:m:s').' '.$i, |
| 86 | 'reg_id' => $reg_data['id____'], |
| 87 | 'assdasd' => $i, |
| 88 | 'e3e3e' => '12345', |
| 89 | 'r4r4r4' => md5($i.'aaaa'), |
| 90 | ); |
| 91 | } |
| 92 | // może być json |
| 93 | // $data = json_encode($data); |
| 94 | $result = $client->addRegisterEntries($reg_data['id____'], $data); |
| 95 | var_dump($result); |
| 96 | |
| 97 | } catch(SoapFault $fault) { |
| 98 | |
| 99 | var_dump($fault); |
| 100 | |
| 101 | if ($fault->faultcode < 100) { |
| 102 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | try { |
| 107 | $data = array( |
| 108 | 'name__' => 'oskar_reg_2', |
| 109 | ); |
| 110 | $max_date = $client->getMaxDateForRegister($data); |
| 111 | var_dump($max_date); |
| 112 | |
| 113 | } catch(SoapFault $fault) { |
| 114 | |
| 115 | var_dump($fault); |
| 116 | |
| 117 | if ($fault->faultcode < 100) { |
| 118 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 119 | } |
| 120 | } |
| 121 | ?> |
| 122 | }}} |
| 123 | Powyższy kod udostępniony jest na licencji LGPL [http://www.gnu.org/licenses/lgpl-3.0.txt] |