https://github.com/olssonm/loopia-api
Simple wrapper for the Loopia XMLRPC-API
https://github.com/olssonm/loopia-api
api loopia php xmlrpc
Last synced: 5 months ago
JSON representation
Simple wrapper for the Loopia XMLRPC-API
- Host: GitHub
- URL: https://github.com/olssonm/loopia-api
- Owner: olssonm
- License: mit
- Created: 2018-06-07T09:00:38.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-23T06:25:13.000Z (almost 5 years ago)
- Last Synced: 2026-01-14T14:43:42.615Z (5 months ago)
- Topics: api, loopia, php, xmlrpc
- Language: PHP
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Loopia API
A super simple wrapper for the [Loopia XML RPC-API](https://www.loopia.se/api/) for PHP.
Relies on [lstrojny/fxmlrpc](https://github.com/lstrojny/fxmlrpc) to make fast and efficient calls to the API. Requires PHP ^7.2 or PHP ^8.0.
## Installation
``` bash
$ composer require olssonm/loopia-api
```
## Usage
Using the package is straight forward – just include the client, create an instance and make your calls.
All methods are listed over at the [Loopia API-documentation](https://www.loopia.se/api/).
**Get all your domains**
``` php
use Olssonm\LoopiaApi\Client;
$response = (new Client('username', 'password'))
->getDomains()
->getResponse();
```
If needed, you may of course separate your code, like so:
``` php
use Olssonm\LoopiaApi\Client;
$client = new Client('username', 'password');
$client->getDomains();
$response = $client->getResponse();
```
**Check the zone records for a domain (with subdomain)**
``` php
use Olssonm\LoopiaApi\Client;
$response = (new Client('username', 'password'))
->getZoneRecords('example.com', '@')
->getResponse();
```
**Update your DNS (name)-servers**
``` php
use Olssonm\LoopiaApi\Client;
$response = (new Client('username', 'password'))
->updateDNSServers('example.com', ['ns1.loopia.se', 'ns2.loopia.se'])
->getResponse();
```
**Update your zone records**
``` php
use Olssonm\LoopiaApi\Client;
$response = (new Client('username', 'password'))
->updateZoneRecord('example.com', '@', [
'type' => 'A',
'ttl' => '3600',
'priority' => 10,
'rdata' => '74.125.0.0',
'record_id' => 0
])
->getResponse();
```
## Testing
Copy `/tests/boot.example.php` to `/tests/boot.php` and edit your settings. Then run:
``` bash
vendor/bin/phpunit --bootstrap ./tests/boot.php ./tests/LoopiaApiTests.php
```
Of course the domain under testing needs to be owned by your Loopia account. **Note:** The last test (`test_update_name_servers`) actually modifies your name servers, use with caution.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
© 2021 [Marcus Olsson](https://marcusolsson.me).