Nieuwe API NH

This commit is contained in:
2022-03-16 13:49:38 +01:00
parent 52de4fcaaa
commit ab9900ac12
2 changed files with 6 additions and 4 deletions

View File

@@ -375,12 +375,12 @@ QUERY
if($externalId = (int)$item['data']->external_id) {
try {
$externalSource = json_decode(file_get_contents($url = $this->EXTERNAL_NEWS_API . 'news?source=api&externalid=' . (int)$externalId));
$externalSource = json_decode(file_get_contents($url = $this->EXTERNAL_NEWS_API . 'article/' . (int)$externalId));
if($externalSource) {
$data['version'] = 2;
$data['source'] = $externalSource->news;
$data['source'] = $externalSource->article;
}
} catch(\Exception $ex) { $data['error'] = array('source' => $url, 'exception' => $ex); }
} catch(\Exception $ex) { $data['error'] = array('source' => $url, 'exception' => $ex->getMessage()); }
}
return response()->json($data);

View File

@@ -49,7 +49,9 @@ class Model {
$text = preg_replace('/\b(?!bel|fm|nh)([a-z]{1,3})\b/u', '', $text);
// Vervang alles dat niet een woord-karakter is (letter, cijfer), een streepje of spatie
$text = preg_replace('/[^\w_\-\s]/', '', $text);
if(strlen($text) > 3) {
$text = preg_replace('/[^\w_\-\s]/', '', $text);
}
// Reeksen van één of meer spaties / streepjes vervangen door een enkel streepje
$text = preg_replace('/[\-\s]+/', '-', $text);