/
LockLizardAdminAPI.php
1398 lines (1093 loc) · 38.9 KB
/
LockLizardAdminAPI.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
namespace LockLizardAdminAPI;
/**
* Class LockLizardAdminAPI
* Wrapper for the LockLizard Enterprise v4 Admin
* https://github.com/edtownend/locklizard-admin-api
* @author Edward Townend <edward@townend.co>
*/
Class LockLizardAdminAPI {
/**
* The LockLizard Admin server base URL without trailing slash
* @var string
*/
private $serverUrl;
/**
* LockLizard Admin server username
* @var string
*/
private $username;
/**
* LockLizard Admin server password
* @var string
*/
private $password;
/**
* Timeout in seconds for API requests
* @var integer
*/
private $timeout = 15;
/**
* Timezone used for DateTime objects
* @var DateTimeZone
*/
private $timezone;
/**
* These parameters have maximum input
* and the request will be chunked if those limits are exceeded
* @var array
*/
private $chunkable = [
'custid',
'publication',
'document',
'pubid',
'docid',
];
/**
* The maximum number of IDs in each chunkable param
* In V4 the limit is actually 200 IDs, BUT that's in total over all the chunkable params. BAH
* TODO: more intelligently chunk to meet this limit
* @var integer
*/
private $chunkSize = 100;
/**
* Keys for matching customer data to values
* Only included the keys that are in every customer
* request, have to add some on for some requests
* @var array
*/
private $customerParams = array(
'id',
'name',
'email',
'company_name',
'valid_from',
'expires_at',
'licenses',
'active',
'registered',
);
/**
* Keys for matching document data to values
* @var array
*/
private $documentParams = array(
'id',
'title',
'published_at',
'expires_at',
'protection_type',
'web_viewer',
);
/**
* Keys for matching customer/document access data to values
* @var array
*/
private $customerDocumentParams = array(
'document_id',
'customer_id',
'customer_name_and_email',
'customer_company_name',
'timestamp',
);
/**
* Called on instantiation
* @param string $serverUrl Base URL for admin server
* @param string $username Username for admin server
* @param string $password Password for admin server
*/
function __construct($serverUrl, $username, $password) {
// Strip trailing slash from url
$this->serverUrl = preg_replace('/\/$/', '', $serverUrl);
$this->username = $username;
$this->password = $password;
// LockLizard API always returns times in GMT
$this->timezone = new DateTimeZone('GMT');
return $this;
}
/**
* Build the URL for an admin request from an action
* @param string $action API action to perform
* @param array $extra Additional GET arguments
* @return string The full URL for the request
*/
private function buildUrl($action, $extra = array())
{
// http_build_query handles urlencoding
$params = array(
'un' => $this->username,
'pw' => $this->password,
'action' => $action,
);
$params = array_merge($params, $extra);
$queryString = http_build_query($params);
return $this->serverUrl . '/Interop.php' . '?' . $queryString;
}
/**
* Send an API request, chunking as necessary
* @param string $url URL to POST to
* @param array $data Request body
* @return string response body
*/
private function send($url, $data = array())
{
// check for chunkable parameters
$chunked = array();
foreach ( $this->chunkable as $key ) {
if ( array_key_exists($key, $data) ) {
$exploded = explode(',', $data[$key]);
if (count($exploded) > $this->chunkSize) {
$chunked[$key] = array_chunk($exploded, $this->chunkSize);
unset($data[$key]);
}
}
}
if ( empty($chunked) ) {
return $this->sendPost($url, $data);
} elseif ( count($chunked) === 1 ) {
$key = key($chunked);
foreach ( $chunked[$key] as $chunk ) {
$thisData = $data;
$thisData[$key] = implode(',', $chunk);
$res = $this->sendPost($url, $thisData);
$out = $this->parseData($res);
if ( $out['status'] !== 'OK' ) {
// abort!
return $res;
}
}
return $res;
} else {
foreach ( $chunked as $key1 => $chunks1 ) {
// avoid same key appearing in inner array
unset($chunked[$key1]);
foreach ( $chunks1 as $chunk1 ) {
foreach ( $chunked as $key2 => $chunks2 ) {
foreach ( $chunks2 as $chunk2 ) {
$thisData = $data;
$thisData[$key1] = implode(',', $chunk1);
$thisData[$key2] = implode(',', $chunk2);
$res = $this->sendPost($url, $thisData);
$out = $this->parseData($res);
if ( $out['status'] !== 'OK' ) {
// abort!
return $res;
}
}
}
}
}
return $res;
}
}
/**
* Send a POST request
* @param string $url URL to POST to
* @param array $data Request body
* @return string response body
*/
private function sendPost($url, $data = array())
{
// Use native WordPress functionality if found
if ( function_exists('wp_remote_post') ) {
$response = wp_remote_post($url, array(
'body' => $data,
'timeout' => $this->timeout,
));
if ( is_wp_error( $response ) ) {
throw new Exception($response->get_error_message());
}
return $response['body'];
}
// Curl fallback
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
curl_close($curl);
if ($response) {
return $response;
} else {
throw new Exception(curl_error($curl));
}
}
/**
* Parse the status and response data returned from LockLizard
* @param string $data raw response body
* @return array
*/
private function parseData($data)
{
// split by line
$data = preg_split('/\n|\r/', $data, -1, PREG_SPLIT_NO_EMPTY);
$output = [];
$output['status'] = array_shift($data);
$output['data'] = $data;
return $output;
}
/**
* Parse data arrays from an array of admin response lines.
* Recognises and correctly formats dates, timestamps and boolean values
* @param array $lines Each line from the admin response as an array item
* @return array Array of arrays
*/
private function parseArraysFromLines($lines)
{
foreach ($lines as $i => $line) {
$line = explode('" "', $line);
// Standardise formats
$line = array_map(function($item){
$val = preg_replace('/^"|"$/', '', $item);
if ( $val === 'true' || $val === 'yes' ) {
return true;
} elseif ( $val === 'false' || $val === 'no' ) {
return false;
} elseif ( preg_match("/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/", $val) ) {
// Dates
return DateTime::createFromFormat('m-d-Y', $val, $this->timezone);
} elseif ( preg_match("/^[0-9]{2}-[0-9]{2}-[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}$/", $val) ) {
// Timestamps
return DateTime::createFromFormat('m-d-Y H:i:s', $val, $this->timezone);
} else {
return stripslashes($val);
}
}, $line);
$lines[$i] = $line;
}
return $lines;
}
/****************************
PUBLIC METHODS
****************************/
/**
* Set the timeout for API requests
* @param int $value timeout in seconds
*/
public function setTimeout($value)
{
$this->timeout = $value;
}
/**
* Get a list of all customers
* @param boolean $webOnly list only customers with Web Viewer access
* @param boolean $pdcOnly list only customers without Web Viewer access
* @return array
*/
public function listCustomers($webOnly = false, $pdcOnly = false)
{
$url = $this->buildUrl('list_customers');
$response = $this->send($url, array(
'webonly' => $webOnly,
'pdconly' => $pdcOnly,
));
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
foreach ( $data as $i => $line ) {
$params = $this->customerParams;
$params[] = 'web_viewer';
$params = array_slice($params, 0, count($line));
$data[$i] = array_combine($params, $line);
}
$output['data'] = $data;
}
return $output;
}
/**
* Get details for a customer by ID or email
* @param string $type 'email' or 'id', type of ID to use
* @param string $id ID or email
* @param bool $noDocs set to true to prevent the listing of document IDs
* @return array
*/
public function listCustomer($type, $id, $noDocs = false)
{
$url = $this->buildUrl('list_customer');
$data = array(
'nodocs' => $noDocs,
);
switch ($type) {
case 'email':
$data['email'] = $id;
break;
default:
$data['custid'] = $id;
break;
}
$response = $this->send($url, $data);
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data'])[0];
$params = $this->customerParams;
if ( $noDocs ) {
$params[] = 'web_viewer';
} else {
$params[] = 'documents';
$params[] = 'publications';
$params[] = 'web_viewer';
}
// Slice off web_viewer if the API hasn't returned a value for it
$params = array_slice($params, 0, count($data));
$data = array_combine($params, $data);
if ($data['documents']) {
// Have to filter because LockLizard adds a trailing comma
$data['documents'] = array_filter(explode(',', $data['documents']));
}
if ($data['publications']) {
$data['publications'] = array_filter(explode(',', $data['publications']));
}
$output['data'] = $data;
}
return $output;
}
/**
* Show the documents and publications all customers have access to
* and whether they have registered or not
* @param boolean $webOnly list only customers with Web Viewer access
* @param boolean $pdcOnly list only customers without Web Viewer access
* @return array
*/
public function listCustomersAccess($webOnly = false, $pdcOnly = false)
{
$url = $this->buildUrl('list_customers_access');
$response = $this->send($url, array(
'webonly' => $webOnly,
'pdconly' => $pdcOnly,
));
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
foreach ( $data as $i => $line ) {
$params = $this->customerParams;
$params[] = 'documents';
$params[] = 'publications';
$params[] = 'web_viewer';
// Slice off web_viewer if the API hasn't returned a value for it
$params = array_slice($params, 0, count($line));
$data[$i] = array_combine($params, $line);
if ($data[$i]['documents']) {
// Have to filter because LockLizard adds a trailing comma
$data[$i]['documents'] = array_filter(explode(',', $data[$i]['documents']));
}
if ($data[$i]['publications']) {
$data[$i]['publications'] = array_filter(explode(',', $data[$i]['publications']));
}
}
$output['data'] = $data;
}
return $output;
}
/**
* This command is used to list the number of customers you have.
* @param bool $webonly count only customers with Web Viewer enabled
* @return array
*/
public function getCustomersCount($webOnly = false)
{
$url = $this->buildUrl('get_customers_count');
$response = $this->send($url, array(
'webonly' => $webOnly
));
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* This command is used to add a new customer to the Administration system.
* @param string $name Customer name
* @param string $email Customer email. If already exists, will update the existing customer
* @param int $licenses Number of licenses. Must be greater than 0
* @param string $companyName Company name - optional
* @param string $startDate Date the account becomes valid from. Optional. MM-DD-YYYY
* @param string $endDate Date the account stops being valid from. Optional. MM-DD-YYYY
* @param array $publicationIds array of publication IDs to grant access to
* @param bool $noRegEmail Suppress the registration email
* @param bool $webViewer Permit Web Viewer access
*/
public function addCustomer(
$name,
$email,
$licenses,
$companyName = '',
$startDate = '',
$endDate = '',
$publicationIds = array(),
$noRegEmail = true,
$webViewer = false
) {
$url = $this->buildUrl('add_customer');
if ( ! $startDate ) {
$startDate = date('m-d-Y');
}
$data = array(
'name' => $name,
'email' => $email,
'company' => $companyName,
'start_date' => $startDate,
'licenses' => $licenses,
'noregemail' => $noRegEmail,
'webviewer' => $webViewer,
);
if ( ! empty($publicationIds) ) {
$data['publication'] = implode(',', $publicationIds);
}
if ( $startDate && $endDate ) {
$data['end_type'] = 'date';
$data['end_date'] = $endDate;
} else {
$data['end_type'] = 'unlimited';
}
$response = $this->send($url, $data);
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines((array)$output['data']);
if ( $webViewer ) {
$data = array(
'id' => $data[0][0],
'username' => $data[1][0],
'password' => $data[2][0],
);
} else {
$data = array(
'id' => $data[0][0],
);
}
$output['data'] = $data;
}
return $output;
}
/**
* Suspend a customer account.
* @param int $customerId customer ID to suspend
* @return array
*/
public function suspendCustomer($customerId)
{
$url = $this->buildUrl('suspend_customer');
$response = $this->send($url, array('custid' => $customerId));
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* Enable a customer account.
* @param int $customerId customer ID to enable
* @return array
*/
public function enableCustomer($customerId)
{
$url = $this->buildUrl('enable_customer');
$response = $this->send($url, array('custid' => $customerId));
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* This command is used to update the start and expiry dates of a customer’s account.
* @param int $customerId ID of the customer to update
* @param string $startDate Optional, leave blank to not change Format: MM-DD-YY
* @param string $endType 'date' or 'unlimited'
* @param string $endDate Required if end_type is set to 'date' Format MM-DD-YY
* @return array
*/
public function updateCustomerAccountValidity(
$customerId,
$startDate = '',
$endType = 'unlimited',
$endDate = ''
) {
$url = $this->buildUrl('update_customer_account_validity');
$response = $this->send($url, [
'custid' => $customerId,
'start_date' => $startDate,
'end_type' => $endType,
'end_date' => $endDate,
]);
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* Set customer license count
* @param int $customerId ID of the customer to update
* @param int $licenses number of licenses to grant.
* 0 removes all licenses from an account.
* @return array
*/
public function setCustomerLicenseCount($customerId, $licenses)
{
$url = $this->buildUrl('set_customer_license_count');
$response = $this->send($url, array(
'custid' => $customerId,
'licenses' => $licenses
));
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* Update customer license count - Adds x to available licenses
* @param int $customerId ID of the customer to update
* @param int $licenses number of licenses to increment by.
* @return array
*/
public function updateCustomerLicenseCount($customerId, $licenses)
{
$url = $this->buildUrl('update_customer_license_count');
$response = $this->send($url, array(
'custid' => $customerId,
'licenses' => $licenses
));
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* Get the license file for a customer
* @param int $customerId ID of the customer
* @param boolean $link return a link to the file instead of the file body
* @return array
*/
public function getCustomerLicense($customerId, $link = false)
{
$url = $this->buildUrl('get_customer_license');
$response = $this->send($url, array(
'custid' => $customerId,
'link' => $link
));
$output = $this->parseData($response);
// If successful, the API breaks convention in not returning a status
// so we'll revert back to the standard
if ($output['status'] === 'Failed') {
return $output;
} else {
return array(
'status' => 'OK',
'data' => $response,
);
}
}
/**
* Grant or deny access to the Web Viewer for an existing user
* or to change their Web Viewer login credentials.
* @param int $customerId ID of the customer to update
* @param bool $permit set true to permit access to WebViewer
* @param string $username Optional if account previously had Web Viewer access
* @param string $password Optional if account previously had Web Viewer access
* @param boolean $noEmail Suppress the registration email
* @return array
*/
public function setCustomerWebViewerAccess(
$customerId,
$permit,
$username = '',
$password = '',
$noEmail = true
) {
$url = $this->buildUrl('set_customer_webviewer_access');
$response = $this->send($url, array(
'custid' => $customerId,
'webviewer' => $permit,
'username' => $username,
'password' => $password,
'noregemail' => $noEmail,
));
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
$data = array_combine(array(
'username',
'password'
), $data);
$output['data'] = $data;
}
return $output;
}
/**
* Get the Web Viewer access status for a customer
* @param int $customerId customer ID to retrieve access status for
* @return array
*/
public function getCustomerWebViewerAccess($customerId)
{
$url = $this->buildUrl('get_customer_webviewer_access');
$response = $this->send($url, array('custid' => $customerId));
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
$data = array_combine(array(
'has_access',
'username',
'password'
), $data);
$output['data'] = $data;
}
return $output;
}
/**
* List the documents the customer(s) has viewed
* Note: this command is only relevant for documents that have view logging enabled.
* @param int/array of ints $customerIds IDs of the customers to retrieve view counts for
* @param int/array of ints $documentIds Optional document IDs to constrain to
* @return array
*/
public function listCustomerViews($customerIds, $documentIds = '')
{
$url = $this->buildUrl('list_views');
if ( is_array($customerIds) ) {
$customerIds = implode(',', $customerIds);
}
if ( is_array($documentIds) ) {
$documentIds = implode(',', $documentIds);
}
$response = $this->send($url, array(
'custid' => $customerIds,
'docid' => $documentIds,
));
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
foreach ( $data as $i => $line ) {
$data[$i] = array_combine($this->customerDocumentParams, $line);
}
$output['data'] = $data;
}
return $output;
}
/**
* Update the number of views the customer has available
* @param int $customerId ID of the customer to update
* @param int $documentId ID of the document to update
* @param int $views Number of views available
* @return array
*/
public function updateCustomerViews($customerId, $documentId, $views)
{
$url = $this->buildUrl('update_views');
$response = $this->send($url, array(
'custid' => $customerId,
'docid' => $documentId,
'views' => $views,
));
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* List the documents the customer(s) has printed
* Note: this command is only relevant for documents that have print logging enabled.
* @param int/array of ints $customerIds IDs of the customers to retrieve print counts for
* @param int/array of ints $documentIds Optional document IDs to constrain to
* @return array
*/
public function listCustomerPrints($customerIds, $documentIds = '')
{
$url = $this->buildUrl('list_prints');
if ( is_array($customerIds) ) {
$customerIds = implode(',', $customerIds);
}
if ( is_array($documentIds) ) {
$documentIds = implode(',', $documentIds);
}
$response = $this->send($url, array(
'custid' => $customerIds,
'docid' => $documentIds,
));
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
foreach ( $data as $i => $line ) {
$data[$i] = array_combine($this->customerDocumentParams, $line);
}
$output['data'] = $data;
}
return $output;
}
/**
* Update the number of prints the customer has available
* @param int $customerId ID of the customer to update
* @param int $documentId ID of the document to update
* @param int $prints Number of prints available
* @return array
*/
public function updateCustomerPrints($customerId, $documentId, $prints)
{
$url = $this->buildUrl('update_prints');
$response = $this->send($url, array(
'custid' => $customerId,
'docid' => $documentId,
'prints' => $prints,
));
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;
}
/**
* List the publication IDs and names for all publications
* @return array
*/
public function listPublications()
{
$url = $this->buildUrl('list_publications');
$response = $this->send($url);
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
foreach ( $data as $i => $line ) {
$data[$i] = array_combine(array(
'id',
'name',
), $line);
}
$output['data'] = $data;
}
return $output;
}
/**
* List the customer IDs with access to each publication ID
* @return array
*/
public function listPublicationCustomers()
{
$url = $this->buildUrl('list_publications_customers');
$response = $this->send($url);
$output = $this->parseData($response);
if ($output['status'] === 'OK') {
$data = $this->parseArraysFromLines($output['data']);
foreach ( $data as $i => $line ) {
$data[$i] = array_combine(array(
'publication_id',
'customer_id',
), $line);
}
$output['data'] = $data;
}
return $output;
}
/**
* Get the number of publications in the system
* @return array
*/
public function getPublicationsCount()
{
$url = $this->buildUrl('get_publications_count');
$response = $this->send($url);
$output = $this->parseData($response);
$output['data'] = reset($output['data']);
return $output;