sah-comp / wobb

Calculations and statistics for EU slaughterhouses
3 stars 0 forks source link

Check Tierwohl qualification via public database instead of earmark flag #45

Closed sah-comp closed 2 years ago

sah-comp commented 3 years ago

Currently the check if a deliverer qualifies for Tierwohl is done by checking for a flag like asterisk * at the end of the earmark. This should be changed to check for the VVVO number against the public QS Tierwohl database.

sah-comp commented 2 years ago

The public QS database requires a cookie to be set. I have to do further investigations.

For the below code, @see https://stackoverflow.com/questions/2138527/php-curl-and-http-post-example

<?php

//
// A very simple PHP example that sends a HTTP POST to a remote site
//

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://datenbank.initiative-tierwohl.de/QSTierwohl/start/do");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt(
    $ch,
    CURLOPT_POSTFIELDS,
    "QsStandortnummern_panelSuchfunktion=276055580440083&IdProduktionsart_panelSuchfunktion=2001"
);

// In real life you should use something like:
// curl_setopt($ch, CURLOPT_POSTFIELDS,
//          http_build_query(array('postvar1' => 'value1')));

// Receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);

curl_close($ch);

// Further processing ...
//if ($server_output == "OK") { ... } else { ... }
var_dump($server_output);
sah-comp commented 2 years ago

This is how to use a SOAP-Client to query the QS/TW database:


<?php
/**
 * QS/ITW SoapClient
 */

// Initialize WS with the WSDL
$client = new SoapClient("https://test.qs-plattform.de/axis/services/rpcrouter?wsdl");
//$client = new SoapClient("https://www.q-s.de/services/files/datenbank/schlachtbetriebe/open_access_akt.wsdl");
//https://www.q-s.de/services/files/datenbank/schlachtbetriebe/open_access_akt.wsdl

// Invoke WS method (Function1) with the request params

$response = $client->selectQSTW([
    'locationId' => '276055660840405',
    'btartId' => '2001'
]);
/*
$response = $client->selectQSTW([
    'locationId' => '276055540645405',
    'btartId' => '2001'
]);
*/

// Print WS response
var_dump($response);