foxentry / php-api-client
Foxentry.com PHP API client
Installs: 6 765
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 2
Open Issues: 1
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- phpunit/phpunit: ^11.3.1
README
Introduction
The Foxentry PHP API Client library enables seamless integration of various data validation features into your applications. Whether you require validation for phone numbers, addresses, emails, or other data types, this library offers a user-friendly interface to interact with the Foxentry API. For more comprehensive information about Foxentry, please visit foxentry.com
If you have questions or need further assistance, reach out to us at info@foxentry.cz
Requirements
To use the Foxentry API client, you need the following:
- A Foxentry account
- An Application project created with a generated API key
- PHP version 7.4 or higher
Installation
To begin using the Foxentry PHP API Client library, follow these installation steps:
With Composer
- Install the library using Composer:
composer require foxentry/php-api-client
- Include the Composer autoloader in your PHP script:
require_once 'vendor/autoload.php';
Without Composer
- Download the library and add it to your project.
- Include the file vendor/autoload.php in your PHP script.
include_once "foxentry-php-client/vendor/autoload.php"
Getting started
To initiate the usage of the Foxentry PHP API Client library, create an instance of the API client with your API key. This instance allows you to access various resources (e.g., phone, location, email, etc.) and call their methods to access the Foxentry API's functionalities.
Full example of e-mail validation
// Require the autoloader file to load necessary dependencies from the "vendor" directory. require "vendor/autoload.php"; // Import the Foxentry\ApiClient class, making it available for use in this script. use Foxentry\ApiClient; /* Create a new instance of the ApiClient class and provide your API key. The API key can be generated in the Foxentry administration under Settings > API Keys section. */ $api = new ApiClient(); $api->setAuth("[YOUR API KEY]"); // Set custom parameters for the email validation request. $response = $api->email() ->setCustomId("CustomRequestID") // Sets a custom request ID. ->setClientIP("127.0.0.1") // Sets the client IP address. ->includeRequestDetails() // Returns the request in API response ->setClientCountry("CZ") // Sets the client country code. ->setOptions([ "acceptDisposableEmails" => false // Disables acceptance of disposable emails. ]) ->validate("info@foxentry.cz"); // Sends request to Foxentry API and performs email validation. // Displays the result of email validation. echo $response->getResult()->isValid ? "E-mail is Valid" : "E-mail is invalid";
APIClient class
The APIClient class is the main class responsible for communication with the API.
It offers the following methods:
To access various resources from this class, simply provide the resource name, and you will be able to access the resource's methods, e.g., $api->email()->search($query)
, $api->company()->get($query)
, etc.
Resources
The API client provides various resources, each with its own related methods listed below. You can click on the methods to navigate to the API documentation, where you can explore all request inputs, options, and more.
In each method, you must specify query parameters according to the specific endpoint in the API documentation.
To specify options, use the method setOptions([])
To specify the client, use the methods setClientIP($ip), setClientCountry($country) or setClientLocation($lat, $lon).
Response class
Response class is returned with every request providing methods below:
Testing
The library includes unit tests to ensure its functionality and provide examples of how the library can be used. You can run the unit tests using PHPUnit. Don't forget to set your API key for these tests by creating the phpunit.xml file.