Superfecta Herold Austria

hi ppl,

I wanted to use superfect with herold austria - it is not working anymore - I already tried to use the latest code (Mar 2017) but it is not working… is there anybody who can help me on that one?

thanks hubert

I’m in Argentina and Superfecta has the plugin for “White Pages” in Argentina. After a change in the code of the White Pages website, the plugin stopped working.

What I did was manually search for a number on the White Pages website and look at the source code of the reply, and then I edited the match pattern of the plugin to make it look for the new source code. Once I knew it was working as expected, I created a bug report on issues.freepbx.org to get the module fixed.

Hope it helps you.

one of the community members patched this recently. The problem with sources that don’t have an official API is that they change at will. It is possible their changes are on purpose to break automated lookups

Hallo Hubert,
i patched the Herold Module on march to get it working again. Herold launched a new Homepage at this time and the module was broken. But for now it still works with our PBX.
In which format does your trunk provider send the cid number?

Scheme Asked is: Default
The DID is: 5555555555
The CNUM is: 07252799
The CNAME is: CID Superfecta!

Starting scheme Default
 Executing Asterisk Phonebook
Searching Asterisk Phonebook ... 
not found
result  took 0.0011 seconds.

 Executing Herold Austria
Searchinghttps://www.herold.at/ ... 
'Mitterhuemer MENSCH | ENERGIE | TECHNIK'
result  took 0.5340 seconds.

Converting result to UTF-8
Post CID retrieval processing
Done
This scheme would set the caller id to: Mitterhuemer MENSCH | ENERGIE | TECHNIK

Returned Result would be: Mitterhuemer MENSCH | ENERGIE | TECHNIK
result took 0,54131889343262 seconds

The same worked with 0043xxx and +43xxx

Herold already offers a beta api since a few weeks. But not for free. You will have to pay per request and its not cheap.

For me the question is how long the html page lookups will work once they launched their api officially.

Hi Matthias,

as I wrote before I have the latest module online but when my Perfecta (Herold) is not working:

Debug is on and set at level: 3
The Original Number: 0463596453
The Scheme: Default
Scheme Type: SINGLEFECTA
Debugging Enabled, will not stop after first result

Scheme Asked is: Default
The DID is: 5555555555
The CNUM is: 0463596453
The CNAME is: CID Superfecta!

Starting scheme Default
Executing Herold Austria
Searchinghttps://www.herold.at/ ...
Search URL=https://www.herold.at/telefonbuch/was_0463596453/
name lookup timed out
Orignal Raw Returned Data:


Returned Content (w/Stripped \n\r\t):

Testing pattern=~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~
Dumping Matches

array(0) {
}


Search URL=https://www.herold.at/gelbe-seiten/was_0463596453/
name lookup timed out
Orignal Raw Returned Data:


Returned Content (w/Stripped \n\r\t):

Testing pattern=~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~
Dumping Matches

array(0) {
}


result took 6.0016 seconds.

This scheme would set the caller id to:

Returned Result would be:
result took 6.005068063736 seconds

Interesting thing is - when I copy that link into a browser, the name is resolved properly - do you have any idea on fixing this?

thanks, Hubert

Which Version do you use?
Testing pattern should be
Testing pattern=~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~

Starting scheme Default
Executing Herold Austria
Searchinghttps://www.herold.at/ …
'Kapsch Brigitte’
result took 0.6379 seconds.

Converting result to UTF-8
Post CID retrieval processing
Done
This scheme would set the caller id to: Kapsch Brigitte

Returned Result would be: Kapsch Brigitte
result took 0,64443492889404 seconds

But Superfecta said “Name lookup timed out.” Check your dns settings and internet connection inside your pbx.
There is maybe a problem that freepbx cannot load this url.

hi Matthias,

yes I also was suspiciious about that timed out. But I have complete access to the internet and also dns is resolving properly…

I have the newest version of superperfecta reinstalled…do I have to do anything else?

thx, Bernhard

PS: do you have also knowledge about certificates for freepbx?

No, it should work. You can try to open the url from the pbx with curl and check the output. I tried superfecta with a few customer pbx systems and all work with your number.

We use letsencrypt with the cert manager and provision the phones with tls/srtp.
What do you want to know?

hi Matthias,

I did the following: curl https://www.herold.at/telefonbuch/was_0463596453/ > test.html and in the html I find Kapsch Brigitte…:frowning: so this seems to work properly?

because of the certificates - I wanted to apply for letsencrypt. the problem is that my freepbx has a public ip which is natted through another public ip (German Hetzner provider). so letsencrypt always gets the wrong IP for my FQDN…

and I am not sure if this is a problem of my provider or my firewall? :frowning: btw: my freepbx runs as a vm on ESXi

thanks, Hubert

LetsEncrypt requires the following hosts to be permitted for inbound http access:
outbound1.letsencrypt.org, outbound2.letsencrypt.org, mirror1.freepbx.org, mirror2.freepbx.org
These entries are correctly set up in the Firewall module. However, it’s possible that other external firewalls may block access. If you are having problems validating your certificate, this could be the issue.

@jfinstrom. Maybe the lookup takes too long? Can we increase the lookup time in the module for testing?

hi Matthias and jfinstrom,

you won’t believe it - accidentally I deleted the current Scheme for superfecta - so I added a new one… and wanted to reproduce the error again - no chance.

with the new scheme its running again without any problem…?!

thanks for the help

HeroldAustria changed the html code on their website again, I had to edit the

source-Herold_Austria.module (already updated on line 52)

<?php

/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 * Developer Notes:
 *
 * There are two separate URLS for reverse searching, one for yellowpages one for ppl:
 *	http://www.herold.at/en/telefonbuch/telefon_$thenumber		- people
 *	http://www.herold.at/en/gelbe-seiten/telefon_$thenumber	 - business
 *  I could only get reverse searches to work for ppl
 *
 * 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
 *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/

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 url we're searching for
		$res_rul = "https://www.herold.at/telefonbuch/was_".$thenumber."/";// url for searching residential listings
		$bus_url = "https://www.herold.at/gelbe-seiten/was_".$thenumber."/";// url for searching business listings

		// regex patterns to search for
		$regexp = array(
			'~<h2><span itemprop="name">(.+?)</span>~',
		);

		// 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);
	}
	}
}

line 52 I changed to '~<h2><span itemprop="name">(.+?)</span>~', originally it was
'~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~',

@Charles_Darwin, thanks for the report. I’ve opened ticket:
https://issues.freepbx.org/browse/FREEPBX-21861

and resolved with commit:
https://git.freepbx.org/projects/FREEPBX/repos/superfecta/raw/sources/source-Herold_Austria.module?at=refs%2Fheads%2Fbugfix%2FFREEPBX-21861

I did a few business and personal lookups and it appears okay. It would be great if you can QA and confirm all is okay as well.

I already installed my edited herold-source-file and it works. Should I test the git-file too? Thanks by the way…as you know, I am a fan of superfecta! it is super useful!!!

Yes please. That’s the version that will be published.

Ok, I will…and report back…later in the evening (European time). Thanks!

1 Like