PHP code example of eugenefvdm / api-collection

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

    

eugenefvdm / api-collection example snippets


return [
    'cpanel' => [
        'username' => env('CPANEL_USERNAME'),
        'password' => env('CPANEL_PASSWORD'),
        'server' => env('CPANEL_SERVER'),
    ],

    'bulksms' => [
        'username' => env('BULKSMS_USERNAME'),
        'password' => env('BULKSMS_PASSWORD'),
        'encoding' => env('BULKSMS_ENCODING', '7bit'),
    ],

    'discord' => [
        'bot_token' => env('DISCORD_BOT_TOKEN'),
    ],

    'hellopeter' => [
        'api_key' => env('HELLOPETER_API_KEY'),
    ],

    'slack' => [
        'webhook_url' => env('SLACK_WEBHOOK_URL'),
    ],

    'telegram' => [
        'bot_token' => env('TELEGRAM_BOT_TOKEN'),
        'chat_id' => env('TELEGRAM_CHAT_ID'),
    ],

    'whm' => [
        'username' => env('WHM_USERNAME'),
        'password' => env('WHM_PASSWORD'),
        'server' => env('WHM_SERVER'),
    ],

    // Use either the API or the database credentials or both
    'whmcs' => [
        'url' => env('WHMCS_URL'),
        'api_identifier' => env('WHMCS_API_IDENTIFIER'),
        'api_secret' => env('WHMCS_API_SECRET'),
        'limitnum' => env('WHMCS_LIMITNUM'),
    ],

    'x' => [
        'bearer_token' => env('X_BEARER_TOKEN'),
        // OAuth 1.0a user-context credentials, only 

use Eugenefvdm\Api\Facades\Bulksms;
Bulksms::sendSms("Hello SMS!", ["27825551231"]);

use Eugenefvdm\Api\Facades\Bulksms;

Bulksms::sendSms("Hello ⭐️", ["27825551232"]);

use Eugenefvdm\Api\Facades\Bulksms;

Bulksms::sendUnicodeSms("Hello ⭐️", ["27825551232"]);
Bulksms::encoding("16bit")->sendSms("Hello ⭐️", ["27825551232"]);

use Eugenefvdm\Api\SmsText;

$message = SmsText::limit("Hello ⭐️", encoding: "16bit", parts: 1);

use Eugenefvdm\Api\Facades\Bulksms;
use Eugenefvdm\Api\HellopeterReviewSms;

$message = HellopeterReviewSms::shorten(
    "You received a ⭐️⭐️⭐️⭐️⭐️ review by Eugene at Hellopeter. Please reply ASAP."
);

Bulksms::sendUnicodeSms($message, ["27825551233"]);

Bulksms::sendSms("Hello SMS!", ["27825551234","27825551235"]);

$discordUser = Discord::user("123456789012345678");

$nsRecords = Dns::NS("example.com");

$digMxRecords = Dns::MX("example.com"); // Use `dig` to get MX records
$nativeMxRecords = Dns::MX("example.com", false); // Use PHP native to get MX recorss

Fail2ban:setServer("username", "hostname", 22); // Port is optional
$firstEntry = Fail2ban::first("192.168.1.1");
$lastEntry = Fail2ban::last("192.168.1.1");

$unrepliedReviews = Hellopeter::unrepliedReviews();

Slack::sendText("Hello Slack!");

Tail::setServer("username", "hostname", 22);
$logEntry = Tail::last("/var/log/mail.log", "[email protected]", 1); // 1 = optional number of log entries to return

Telegram::sendMessage("Hi Telegram!");

$bandwidth = Whm::bandwidth();
Whm::suspendEmail('cPanel_username', '[email protected]');
Whm::unsuspendEmail('cPanel_username', '[email protected]');
$whitelist = Whm::cphulkWhitelist();
$blacklist = Whm::cphulkBlacklist();
Whm::createEmail('cpanel_username', '[email protected]', 'password');
Whm::deleteEmail('cpanel_username', '[email protected]');
$password = Whm::generatePassword(); // Generate a random 12 character password

Whmcs::addClient([]); // See `addClient()` in `Whmcs.php` for 

if (Whm::isConfigured()) {
    Whm::createEmail('cpanel_username', '[email protected]', 'password');
}

if (Cpanel::isConfigured()) {
    Cpanel::createEmail('[email protected]', 'password');
}

// Success response
[
    "status" => "success",
    "output" => $output,
]
// Error response
[
    "status" => "error",
    "output" => "Error message here",
]
bash
php artisan vendor:publish --provider="Eugenefvdm\Api\ApiServiceProvider" --tag="config"