| 9 | | /** |
| 10 | | * Wysyla powiadomienie |
| 11 | | * |
| 12 | | * @param array $data |
| 13 | | * @access public |
| 14 | | * |
| 15 | | * @return bool true on success, false otherwise |
| 16 | | * |
| 17 | | * @throws Exception - SoapFault |
| 18 | | */ |
| 19 | | bool notifyUser(array data); |
| | 9 | /** |
| | 10 | * Powiadom pracownika |
| | 11 | * |
| | 12 | * @param data Array - Tablica z parametrami |
| | 13 | * @param data['usr_id'] Int - identyfikator pracownika (users:usr_id) |
| | 14 | * @param data['msgtxt'] String - treść powiadomienia |
| | 15 | * |
| | 16 | * @return True - zawsze zwraca TRUE |
| | 17 | * |
| | 18 | * @throws Exception - SoapFault |
| | 19 | */ |
| | 20 | Int notifyUser(Array data) |
| 26 | | $client->notifyUser(2, "powiadamiam!"); |
| | 29 | // Plik MyService.php umieszczony w apps/edokumenty. |
| | 30 | // MyService.php |
| | 31 | <?php |
| | 32 | |
| | 33 | define('EDOK_API_LOGIN', 'developer'); |
| | 34 | define('EDOK_API_PASSWORD', 'developer'); |
| | 35 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| | 36 | |
| | 37 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| | 38 | |
| | 39 | $options = array( |
| | 40 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| | 41 | "uri" => "eDokumentyAPI", |
| | 42 | 'encoding'=>'UTF-8' |
| | 43 | ); |
| | 44 | |
| | 45 | $client = new EDokApiClient(NULL, $options); |
| | 46 | $client->setUser(EDOK_API_LOGIN); |
| | 47 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| | 48 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| | 49 | $client->__setSoapHeaders($header); |
| | 50 | |
| | 51 | $data = array( |
| | 52 | 'usr_id' => 19, |
| | 53 | 'msgtxt' => 'Ważna wiadomość' |
| | 54 | ); |
| | 55 | |
| | 56 | |
| | 57 | try { |
| | 58 | $out = $client->notifyUser($data); |
| | 59 | var_dump($out); |
| | 60 | } catch(SoapFault $fault) { |
| | 61 | var_dump($fault); |
| | 62 | |
| | 63 | if ($fault->faultcode < 100) { |
| | 64 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| | 65 | } |
| | 66 | } |
| | 67 | |
| | 68 | ?> |
| | 69 | }}} |