1. Go to this page and download the library: Download tousanco/php-zaya 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/ */
tousanco / php-zaya example snippets
use Tousanco\PhpZaya\Link;
use GuzzleHttp\Client;
$apiKey = 'your api key';
// available classes: Link, Space, Domain, Account, Stats.
$instance = Link::instance($apiKey);
// OR
$client = new Client();
$instance = (new Link($client, $apiKey));
use Tousanco\PhpZaya\Link;
$instanceLink = Link::instance($apiKey);
$listParams = [
// All options nullable
// search (string)
'search' => 'search key',
// by (in:title,alias,url) null for all.
'by' => 'title',
// ids comma separated (string)
'ids' => '1,2,3,4,5',
/*
* status (int|in:0,1,2,3,4,5,6)
* 0 or null for all
* 1 for active
* 2 for pending
* 3 for deactivate
* 4 for suspended
* 5 for expired
*/
'status' => 1,
// (int) space-id
'space' => 1,
// (int) domain-id
'domain' => 1,
// favorites (bool|in:1) null for false
'favorites' => 1,
/*
* sort (string|in:desc,asc,max,min)
* max for maximum clicks
* min for minimum clicks
*/
'sort' => 'desc',
];
$links = $instanceLink->all($listParams);
$createOrUpdateParams = [
// All options nullable
'alias' => 'string',
'password' => 'string',
'space' => 'int',
'domain' => 'int',
'disabled' => 'int',
'public' => 'int',
'description' => 'string',
'expiration_url' => 'url',
'expiration_date' => 'Y-m-d',
'expiration_time' => 'HH:MM',
'expiration_clicks' => 'int',
];
$link = $instanceLink->create('https://example.com', $createOrUpdateParams);
$linkId = 1;
$link = $instanceLink->details($linkId);
$link = $instanceLink->update($linkId, $createOrUpdateParams);
$instanceLink->delete($linkId);