-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaquery.php
More file actions
29 lines (23 loc) · 1.1 KB
/
aquery.php
File metadata and controls
29 lines (23 loc) · 1.1 KB
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
<?php
set_time_limit(0);
$ch = curl_init();
$url = 'https://api-eu.hosted.exlibrisgroup.com/almaws/v1/analytics/reports';
//Change the code below to point to your new books analytics query.
//Also, don't forget to add your Analytics API key.
$queryParams = '?' . urlencode('path') . '=' . urlencode('/path/to/AnalyticsReport/A') . '&' . urlencode('limit') . '=' . urlencode('250') . '&' . urlencode('col_names') . '=' . urlencode('true') . '&' . urlencode('apikey') . '=' . urlencode('[PUT YOUR API KEY HERE]');
curl_setopt($ch, CURLOPT_URL, $url . $queryParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$response = curl_exec($ch);
curl_close($ch);
/* creates xml array */
$my_file = 'b_books.xml';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
$data = $response;
fwrite($handle, $data);
$alma_analytics_result_array = simplexml_load_string($response);
$rowset = $alma_analytics_result_array->QueryResult->ResultXml->rowset;
/* build parameter for each value in the analytics results */
$i=0;
?>