-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathquickstart.php
More file actions
55 lines (40 loc) · 1.33 KB
/
Copy pathquickstart.php
File metadata and controls
55 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once 'vendor/autoload.php';
define('APPLICATION_NAME', 'FreeNom Shorten URL API');
define('CREDENTIALS_PATH', '~/.credentials/freenom-php-api.json');
$details = [
'domain' => 'google.com',
'prefix' => 'https://',
'type' => 'FREE'
];
$cli = new Freenom_Client;
$client = $cli->getClient();
try {
$service = new Freenom_Service($client);
$service->ping();
$contact = new Freenom_Contact($client);
var_dump($contact->getList());
var_dump($contact->getInfo(['contactId'=>1]));
$domain = new Freenom_Domain($client);
$listDomains = $domain->listDomains(['maxResults'=>100]);
var_dump($listDomains);
$search = $domain->search([
'name' => $details['domain'],
'type' => $details['type']
]);
var_dump($search);
$register = $domain->shortenURL([
'url' => $details['prefix'].$details['domain']
]);
var_dump($register);
} catch(Freenom_Authorize_Exception $e) {
var_dump(get_class($e), $e->getMessage(), $e->getCode());
} catch(Freenom_Service_Exception $e) {
var_dump(get_class($e), $e->getMessage(), $e->getCode());
} catch(Freenom_Request_Exception $e) {
var_dump(get_class($e), $e->getMessage(), $e->getCode());
} catch(Freenom_Exception $e) {
var_dump(get_class($e), $e->getMessage(), $e->getCode(), $e->getErrorArray());
} catch(Exception $e) {
var_dump(get_class($e), $e->getMessage(), $e->getCode());
}