This PHP library provides an interface for interacting with the Fonial API. It follows PSR-18 (HTTP Client) and PSR-3 (Logger) standards for HTTP requests and logging.
Fonial is not related to this library, it's created solely by the fucodo GmbH.
- Authenticate with the Fonial API
- Retrieve available IP devices
- Retrieve available numbers
- Retrieve call records within a specified time frame
- Retrieve incoming connections within a specified time frame
- PHP 8.0 or higher
- Composer
- PSR-18 HTTP Client implementation (e.g., Guzzle)
- PSR-17 HTTP Factory implementation (e.g., Nyholm PSR-7)
- PSR-3 Logger implementation (e.g., Monolog)
- fonial account
- fonial api access
Install the library via Composer:
composer require fucodo/api-fonial
Before using the API client, you need to initialize it with a PSR-18 HTTP Client, PSR-17 HTTP Factory, and a PSR-3 Logger.
require 'vendor/autoload.php';
use GuzzleHttp\Client as GuzzleClient;
use Nyholm\Psr7\Factory\Psr17Factory;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Fucodo\ApiFonial\FonialApi;
// Initialize the HTTP client and request factory
$client = new GuzzleClient();
$psr17Factory = new Psr17Factory();
// Initialize the logger
$logger = new Logger('fonial');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::INFO));
// Create the Fonial API client
$fonial = new FonialApi($client, $psr17Factory, $logger);
To authenticate with the Fonial API, use the auth
method with your username and password.
try {
$fonial->auth('your_username', 'your_password');
echo "Authentication successful.\n";
} catch (AuthenticationException $e) {
echo "Authentication failed: " . $e->getMessage() . "\n";
} catch (SessionException $e) {
echo "Session error: " . $e->getMessage() . "\n";
}
To retrieve the available IP devices, use the deviceGet
method.
$devices = $fonial->deviceGet();
print_r($devices);
To retrieve the available numbers, use the numbersGet
method.
$numbers = $fonial->numbersGet();
print_r($numbers);
To retrieve call records within a specified time frame, use the evnGet
method.
$callRecords = $fonial->evnGet('2023-01-01 00:00:00', '2023-01-31 23:59:59');
print_r($callRecords);
To retrieve incoming connections within a specified time frame, use the journalGet
method.
$incomingConnections = $fonial->journalGet('2023-01-01 00:00:00', '2023-01-31 23:59:59');
print_r($incomingConnections);
The library throws specific exceptions for authentication and session errors.
Fucodo\ApiFonial\Exception\AuthenticationException
: Thrown when authentication fails.Fucodo\ApiFonial\Exception\SessionException
: Thrown when there is a session error.
This library is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
For any questions or support, please open an issue on GitHub.
This README file provides a comprehensive overview of the Fonial API Client, including installation instructions, usage examples, exception handling, and contact information. Follow the best practices for a clear and informative README to help users understand and utilize the library effectively.