Project Details:
In this project we’ve to integrate a cars listings api “https://gw.bilinfo.net/listingapi/api” to a wordpress site in custom post type with the meta data to be mapped in Custom meta fields in “SCF” plugin.
You can find the API documentation for reference here: “https://developer.bilinfo.net/content/Bilinfo_XML_API.pdf“
In this we will use Curl request to get the listings data from the api with basic authentication of “Username” and “Password” provided by API to make api connection.
Curl Request:
$curl = curl_init();
curl_setopt_array( $curl, array(
CURLOPT_URL => 'https://gw.bilinfo.net/listingapi/api/export',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Basic {authorization user|password}'
),
));
$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
Explanation:
In the above curl request, we will use the api url to make request to api “https://gw.bilinfo.net/listingapi/api/export” with “GET” request method and the headers will be included as basic authorization of “Username” & “Password” that is provided by API. We can also get the request details by using curl_getinfo() method that will provide complete request details sent to api to get cars listings data.
Upon sending this request we will get the api response if our basic authorization and script is correctly formatted. we will get response in json for all the available cars listings in API including these meta (Title, description, Main Image, Gallery Images, features, engine details, mileage, type, price, category etc…) by inserting all these listings to “Custom post type” we will then use “SCF” secure custom fields plugin to map our data as coming from api to SCF custom meta fields on our site.
Hope this blog will help you in integrating gw.bilinfo.net/api to your wordpress site if you want more information or want a custom plugin for this api integration you can contact us here “/contact” or our fiverr profile Fiverr Profile
Site referrences:
1- https://agn.dk/car
2- https://arosleasing.dk/