organic: Add extended API
This commit is contained in:
+5
-5
@@ -121,7 +121,8 @@ if ($country === null) {
|
||||
|
||||
$data = [];
|
||||
|
||||
$url = "https://www.bioc.info/search/producerSearchQuery?search[name]=" . urlencode($name) . "&search[citycode]=" . urlencode($postalCode) . "&search[operatorId]=" . urlencode($idNr) . "&search[country]=$country";
|
||||
$origin = "https://www.bioc.info/search/producersearchresult?producerSearch%5Bcountry%5D={$country}&producerSearch%5Bcitycode%5D=" . urlencode($postalCode) . "&producerSearch%5Bname%5D=" . urlencode($name) . "&producerSearch%5BoperatorId%5D=" . urlencode($idNr);
|
||||
$url = "https://www.bioc.info/search/producerSearchQuery?search[country]={$country}&search[citycode]=" . urlencode($postalCode) . "&search[name]=" . urlencode($name) . "&search[operatorId]=" . urlencode($idNr);
|
||||
$m = curl_multi_init();
|
||||
$requests = [];
|
||||
foreach ($source_groups as $group) {
|
||||
@@ -134,6 +135,7 @@ foreach ($source_groups as $group) {
|
||||
$running = 1;
|
||||
do {
|
||||
curl_multi_exec($m, $running);
|
||||
if ($running) usleep(250_000);
|
||||
} while ($running);
|
||||
foreach ($requests as $r) {
|
||||
curl_multi_remove_handle($m, $r);
|
||||
@@ -141,7 +143,7 @@ foreach ($requests as $r) {
|
||||
curl_multi_close($m);
|
||||
|
||||
foreach ($requests as $s) {
|
||||
if (($json = curl_multi_getcontent($s)) === false) {
|
||||
if (($json = curl_multi_getcontent($s)) === null) {
|
||||
header('Status: 500');
|
||||
header('Content-Length: 34');
|
||||
echo "{\"error\":\"internal server error\"}\n";
|
||||
@@ -153,10 +155,8 @@ foreach ($requests as $s) {
|
||||
}
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
|
||||
$first = true;
|
||||
echo "{\"data\":[\n";
|
||||
echo "{\"originUrl\":\"$origin\",\"data\":[\n";
|
||||
foreach ($data as $id => $row) {
|
||||
if (!$first) echo ",\n";
|
||||
$row = explode("</", $row);
|
||||
|
||||
Reference in New Issue
Block a user