PHP code example of kuza / user-data-capture
1. Go to this page and download the library: Download kuza/user-data-capture library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kuza / user-data-capture example snippets
se Kuza\UserDataCapture\Location;
use Kuza\UserDataCapture\UserAgent;
use Kuza\UserDataCapture\Request;
# Get the user's location details
try {
$location = new Location("path_to_maxmind_db");
$continent_name = $location->continent_name;
$country_name = $location->country_name;
$city_name = $location->city_name;
$latitude = $location->latitude;
$longitude = $location->longitude;
$timezone = $location->timezone;
} catch (\MaxMind\Db\Reader\InvalidDatabaseException $ex) {
echo $ex->getMessage();
} catch (\Exception $ex) {
echo $ex->getMessage();
}
# Get the user's device details
$device = new UserAgent();
$os = $device->platform;
$browser = $device->browser;
$browser_version = $device->version;
$is_mobile = $device->is_mobile;
$is_app = $device->is_app;
$is_bot = $device->is_bot;
# Get request details
$request = new Request();
$request_method = $request->method;
$query_params = $request->query_params;
$body = $request->body;
$headers = $request->headers;
$full_uri = $request->full_uri;
$uri_path = $request->uri_path;