PHP code example of xolphin / xolphin-api-php

1. Go to this page and download the library: Download xolphin/xolphin-api-php 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/ */

    

xolphin / xolphin-api-php example snippets


$dcvDomain = new Xolphin\Requests\DCVDomain('someDomain', Xolphin\Helpers\DCVTypes::EMAIL_VALIDATION, '[email protected]');



nt = new Xolphin\Client('<username>', '<password>');

$limit = $client->getLimit();
echo $limit . PHP_EOL;

$requestsRemaining = $client->getRequestsRemaining();
echo $requestsRemaining . PHP_EOL;

$requests = $client->requests->all();
foreach($requests as $request) {
    echo $request->id . PHP_EOL;
}

$request = $client->requests->get(1234);
echo $request->id;

$products = $client->support->products();

// request Sectigo EssentialSSL certificate for 1 year
$request = $client->requests->create($products[1]->id, 1, '<csr_string>', DCVTypes::EMAIL_VALIDATION)
    ->setAddress("Address")
    ->setApproverFirstName("FirstName")
    ->setApproverLastName("LastName")
    ->setApproverPhone("+12345678901")
    ->setZipcode("123456")
    ->setCity("City")
    ->setCompany("Company")
    ->setApproverEmail('[email protected]')
    //currently available languages defined in RequestLanguages
    ->setLanguage(RequestLanguage::ENGLISH)
    ->addSubjectAlternativeNames('test1.domain.com')
    ->addSubjectAlternativeNames('test2.domain.com')
    ->addSubjectAlternativeNames('test3.domain.com')
    ->addDcv(new \Xolphin\Requests\DCVDomain('test1.domain.com', DCVTypes::EMAIL_VALIDATION, '[email protected]'))
    ->addDcv(new \Xolphin\Requests\DCVDomain('test2.domain.com', DCVTypes::EMAIL_VALIDATION, '[email protected]'));

$client->requests->send($request);

// Reissue a current certificate
$reissue = new \Xolphin\Requests\ReissueRequest('<csr_string>', DCVTypes::EMAIL_VALIDATION);
$reissue->setApproverEmail('[email protected]');

$client->certificates->reissue(<certificate_id>, $reissue);

// Renew a current certificate
$currentCertificate = $client->certificates->get(<certificate_id>);

$renew = new \Xolphin\Requests\RenewRequest($currentCertificate->product, <years>, '<csr_string>', DCVTypes::FILE_VALIDATION);
$renew->setApproverEmail('[email protected]');

$client->certificates->renew(<certificate_id>, $renew);

$result = $client->requests->sendNote(1234, 'My message');

$notes =  $client->requests->getNotes(1234);
foreach($notes as $note){
    echo $note->messageBody . PHP_EOL;
}

//currently available languages defined in RequestLanguages
$client->requests->sendSectigoSAEmail(1234, '[email protected]', RequestLanguage::ENGLISH);

$certificates = $client->certificates->all();
foreach($certificates as $certificate) {
    echo $certificate->id . ' - ' . $certificate->isExpired() . "\n";
}

$certificates = $client->certificates->all();
$cert = $client->certificates->download($certificates[0]->id, CertificateDownloadTypes::CRT);
file_put_contents('cert.crt', $cert);

$products = $client->support->products();
foreach($products as $product) {
    echo $product->id . PHP_EOL;
}

$csr = $client->support->decodeCSR('<your csr string>');
echo $csr->type;

$invoices = $client->invoices->all();
foreach($invoices as $invoice) {
    echo $invoice->id . ' ' . $invoice->invoiceNr . ' ' . $invoice->amount . PHP_EOL;
}

$invoices = $client->invoices->all();
$invoicePdf = $client->invoices->download($invoices[0]->id, InvoiceDownloadTypes::PDF);
file_put_contents('invoice.pdf' , $invoicePdf);

composer 

composer update xolphin/xolphin-api-php