Are you looking for a way to get the IAB category of a website in PHP? Then we’re here to help you!
Every firm must engage with a large number of websites on a daily basis. Most are safe, but others are certain to be hazardous to employee productivity or, worse, their data. Simply defined, website categorization is a method for businesses to classify sites that they often access under different umbrellas for marketing, cybersecurity, and brand protection. Website categories include leisure, commerce, gaming, and others.
Website categorization tools take a domain name or other input, run it through a database of categories (the number of which varies from product to product), and provide results in seconds. These tools can contain anything from 25 to hundreds of different site categories. While most likely relying on their own set of categories, some employ industry-recognized website categorization from organizations such as the Internet Advertising Bureau (IAB).
This may be done on a big scale using specialist technologies, or it can be done manually by accessing vast databases of web sites. For example, you may receive an email from your bank including a link to a certain page. If you’re unsure whether this email and links are genuine, all you have to do is do some investigation. You may just copy and paste the URL to see who is behind the address.
There are many service providers for this, however the quality varies. Website categorization is primarily reliant on the provider’s capacity to evaluate and test current and new domains, as well as regularly update the database. Let’s dive deeper into this.
How To Do Website Categorization In PHP
Website classification is not difficult, especially if you have the correct tools. We strongly advise using an API for this reason. which is a data interface that receives data from a location and returns it to the person who requested it. This allows you to enter a URL into an API-enabled software and get a list of all the categories that website is classified under. You may then use that API for any reason you want and modify it to operate with whatever code you choose.
Since there is a vast amount of APIs for website categorization online, not all of them might bring you the information in PHP, which is what we’re looking for. PHP is a popular open source general-purpose programming language that is ideal for web development and can be integrated in HTML. The PHP code is encased between specific start and end processing instructions?php and?> that allow you to switch between “PHP mode” and “normal mode.”
So, is it hard to find an API for PHP? Well, it might be, but we can give you a little help with that. For getting the category of a website in this programming language, we recommend using Klazify, which is quickly becoming one of the most popular and extensively used APIs. This program gets internet information by evaluating a website’s text content and meta tags using Natural Language Processing (NLP) and a Machine Learning Engine.
To make use of it you have to:
- Sign up for an API key at www.klazify.com.
- Locate and copy any domain that you desire to classify in the designated region. Once you’ve validated that you’re not a robot, submit it.
- You will then receive the API response in one or more programming languages.
- Look through the sections and select the information that is most pertinent to you.
The PHP code should look something like this:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.klazify.com/api/categorize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"url\":\"https://www.google.com\"}\n",
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Authorization: Bearer access_key
",
"Content-Type: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Why Klazify?
Klazify is a search engine that categorizes webpages and businesses according to their field of competence. Klazify’s mission is to identify, compare, and categorize the best websites on the internet (up to 3 levels). Deep learning techniques are used in their search engine, which are not only more accurate than typical classifiers, but also more resilient, allowing you to deal with faulty input data.
Klazify will browse to the required domain name or URL, gather its content, and establish appropriate categorizes based on an IAB V2 Standard classification taxonomy, which may be used for 1-1 personalisation, marketing segmentation, online filtering, and other purposes. As a consequence, the URL or domain may now be assigned to a specified category.
Also published on Medium.