| | 1 | = [wiki:DeployerGuide Przewodnik wdrożeniowca] > Dodaj załącznik do dokumentu = |
| | 2 | |
| | 3 | |
| | 4 | ''' Definicja parametrów: ''' |
| | 5 | {{{ |
| | 6 | #!php |
| | 7 | <?php |
| | 8 | |
| | 9 | /** |
| | 10 | * Dodaje załącznik do dokumentu |
| | 11 | * |
| | 12 | * @param fileContent String - Tablica z parametrami |
| | 13 | * @param fileName String - nazwa pliku |
| | 14 | * @param documentId Int - identyfikator dokumentu (documents:doc_id) |
| | 15 | * @param contentTransferEncoding String - kodowanie przesyłanej treści pliku (tylko base64) |
| | 16 | * |
| | 17 | * @return Int - id pliku jeśli sukces, 0 w razie niepowodzenia |
| | 18 | * |
| | 19 | * @throws Exception - SoapFault |
| | 20 | */ |
| | 21 | Int addAttachmentToDocument(String fileContent, String fileName, Int documentId) |
| | 22 | |
| | 23 | ?> |
| | 24 | }}} |
| | 25 | |
| | 26 | ''' Przykłady wywołań: ''' |
| | 27 | {{{ |
| | 28 | #!php |
| | 29 | |
| | 30 | // Plik MyService.php umieszczony w apps/edokumenty. |
| | 31 | // MyService.php |
| | 32 | <?php |
| | 33 | |
| | 34 | define('EDOK_API_LOGIN', 'developer'); |
| | 35 | define('EDOK_API_PASSWORD', 'developer'); |
| | 36 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| | 37 | |
| | 38 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| | 39 | |
| | 40 | $options = array( |
| | 41 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| | 42 | "uri" => "eDokumentyAPI", |
| | 43 | 'encoding'=>'UTF-8' |
| | 44 | ); |
| | 45 | |
| | 46 | $client = new EDokApiClient(NULL, $options); |
| | 47 | $client->setUser(EDOK_API_LOGIN); |
| | 48 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| | 49 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| | 50 | $client->__setSoapHeaders($header); |
| | 51 | |
| | 52 | // Tworzy kontakt |
| | 53 | $contid = NULL; |
| | 54 | |
| | 55 | try { |
| | 56 | $data = array( |
| | 57 | 'name_1' => 'SOAP TEST'.date('d H:m:s'), |
| | 58 | 'name_2' => 'SOAPTEST', |
| | 59 | 'nip___' => 1111111111, |
| | 60 | 'street' => 'Główna', |
| | 61 | 'symbol' => 'FGH99' |
| | 62 | ); |
| | 63 | $contid = $client->createContact($data); |
| | 64 | var_dump($contid); |
| | 65 | |
| | 66 | } catch(SoapFault $fault) { |
| | 67 | |
| | 68 | var_dump($fault); |
| | 69 | |
| | 70 | if ($fault->faultcode < 100) { |
| | 71 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| | 72 | } |
| | 73 | } |
| | 74 | |
| | 75 | ?> |
| | 76 | }}} |