request('POST', $url, [ 'form_params' => [ 'format' => 1, 'language' => 'en', 'translatedTexts' => 'Printed;Last Change' ] ]); $result = json_decode($res->getBody()->getContents()); if ($result === null || !property_exists($result, 'result')) { exit("The ISBN range API at $url is currently unavailable, exiting...\n"); } $value = $result->result->value; $filename = $result->result->filename; $url = sprintf('https://www.isbn-international.org/?q=download_range/%s/%s', $value, $filename); echo "Getting XML from $url...\n"; $res = $client->request('GET', $url); $xml = $res->getBody()->getContents(); echo "Converting to PHP array...\n"; $ranges = (array) simplexml_load_string($xml); $ranges = json_encode($ranges); $ranges = json_decode($ranges, true); $prefixes = (array) $ranges['EAN.UCCPrefixes']['EAN.UCC']; $groups = (array) $ranges['RegistrationGroups']['Group']; foreach ($groups as &$group) { // Fix entries with a single "range", converting it to an array if (isset($group['Rules']['Rule']['Range'])) { $group['Rules']['Rule'] = array($group['Rules']['Rule']); } } $file = dirname(__FILE__) . '/../src/Biblys/Isbn/ranges-array.php'; echo "Saving to $file...\n"; file_put_contents($file, '