Superfecta Herold Austria not working

The Superfecta Herold Austria source template needs another update (search string)…here’s the working template…

<?php

/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 * Developer Notes:
 *
 *
 * herold.at Terms of Service:
 * As summarized in the post here on 2014-06-27
 * https://github.com/POSSA/Caller-ID-Superfecta/issues/131#issuecomment-47354154
 * herold.at TOS do not explicitly prohibit automated lookups
 *
 * Version History:
 * 2014-06-28	Initial migration from 2.2.x
 * 2014-07-02	Add business lookups and change urls to mobile site
 * 2016-05-03	Rewrite Numbers correct for Herold and change Query for new Mobile Web Template
 * 2017-03-20	Again Herold has a new Theme. We need to change the regexp again
 * 2017-11-09	If the Caller ID is 'unknown', 'anonymous' or empty then skip the check
 * 2020-09-12	update regex per https://community.freepbx.org/t/superfecta-herold-austria/42997/15
 * 2022-06-10   general update per https://community.freepbx.org/t/superfecta-herold-austria-not-working-anymore-they-changed-the-code/83830
 *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/

class Herold_Austria extends superfecta_base {

	public $description;
	public $version_requirement = "2.11";

	public function __construct() {
		$this->description = "https://www.herold.at/ - "._("These listings include data for Austria.");
	}

	function get_caller_id($thenumber, $run_param=array()) {
		$this->DebugPrint(_("Searching"). "https://www.herold.at/ ... ");
		
		if($thenumber !== 'anonymous' && $thenumber !== 'unknown' && $thenumber !== ''){

		if (substr($thenumber, 0, 1) ==! '0') {
			$thenumber=trim($thenumber,' ');
			$thenumber="00" . $thenumber;
		}
		if (substr($thenumber, 0, 2) === '00') {
			$thenumber=trim($thenumber,' ');
		}

		// Set the urls we're searching for
		$res_rul = "https://www.herold.at/telefonbuch/suche/?userTerm=".$thenumber."/";// url for searching residential listings
		$bus_url = "https://www.herold.at/gelbe-seiten/suche/?userTerm=".$thenumber."/";// url for searching business listings		

		// regex patterns to search for
		$regexp = array(
			'~<h2><span itemprop="name">(.+?)</span>~', // reported broken 2022-06-10
            '~<h2 class="business-content_heading__2ED5C"><a itemProp="name" data-clickpos="showdetails" href=".+?">(.+?)</a></h2>~',  // working 2022-06-10
			'~<a rel="nofollow" href=".+?"><h2 class="white-pages-search-result-item_heading__1BDNn">(.+?)</h2></a>~',   // working 2022-06-10
		);

		// first search for Residential match
		if ($this->SearchURL($res_rul, $regexp, $match)) {
			$caller_id = $this->ExtractMatch($match);
		}

		// if no residential match found, search business
		if ($this->SearchURL($bus_url, $regexp, $match)) {
			$caller_id = $this->ExtractMatch($match);
		}
		$caller_id = isset($caller_id)?$caller_id:'';
		


		return($caller_id);
	}
	}
}
1 Like

Thanks, will give it a try. Do you see any advantage compared to TelefonABC Austria?

I always thought that Herold.at has the larger database and that TelefonABC ist not up to date…but maybe I am wrong. Does the Superfecta template for TelefonABC search both TelefonABC and FirmenABC?

The TelefonABC template uses a search string for persons only, no companies. It seems it is not possible to do a reverse lookup for a company number on www.telefonabc.at
The Herold template searches both databases.

1 Like

Thanks a lot for checking, I got the same impression, that TelefonABC does not check FirmenABC.

Btw, have you ever found a setting that enables Superfecta to deal properly with German Umlaute? I’ve tried many combinations regarding encodings and / or stripping accent characters - so far, to no avail.

Do you use freePBX 16? There is a new version of Superfecta available, which lets you set the encodings within the template config (GUI). Very useful! For Herold-Austria I set it to UTF-8 and no (accent character) stripping. It seems to work. In freePBX 15 and older you have to edit the superfecta-class file.

Pull Request for ver 16 with these updates
https://git.freepbx.org/projects/FREEPBX/repos/superfecta/pull-requests/99/overview

1 Like

Yes, FreePBX 16. Unfortunately, this combination does not work for us.
For us, enabling strip accent characters works best (at least the “&” sign is recognized).
Changing the character encoding seems to make no difference.

In freePBX 16 the code of the superfecta.class.php file changed, so I dont know if the alternative code works. Backup the file and try it…
Problem is, you have to deactivate signature checking in advanced settings.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.