PHP code example of 101media / bird

1. Go to this page and download the library: Download 101media/bird 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/ */

    

101media / bird example snippets


use Media101\Bird\Services\ContactService;

$birdContacts = app(new ContactService())->index(limit: 20, reverse: true);

use Media101\Bird\Services\ContactService;

$birdContact = app(new ContactService())->show('bird-contact-id-123');

use Media101\Bird\Models\Contact;
use Media101\Bird\Enums\IdentifierKey;
use Media101\Bird\Services\ContactService;

$contact = (new Contact())
    ->displayName('John Doe')
    ->phoneNumber('+12345678901')
    ->emailAdress('[email protected]');

$response = (new ContactService())->createOrUpdate($contact, IdentifierKey::PHONE_NUMBER);

use Media101\Bird\Services\ContactService;

$response = (new ContactService())->delete('contact-id-123');

if ($response === true) {
    // Successfully deleted the contact
    dd('Contact deleted successfully.');
} else {
    // Handle error
    dd($response);
}

use Media101\Bird\Models\Contact;

$contact = (new Contact())
    ->displayName('Jane Doe')
    ->phoneNumber('+98765432103')
    ->emailAdress('[email protected]')
    ->attribute('company', 'Acme Corp');

// The contact can then be passed to the `ContactService` for API interaction

use Illuminate\Notifications\Notification;
use Media101\Bird\Models\Messages\SMSMessage;
use Media101\Bird\Notifications\Channels\SMSChannel;

class OrderNotification extends Notification
{
    public function via(): array
    {
        return [ SMSChannel::class ];
    }

    public function toSMS($notifiable): SMSMessage
    {
        $contact = (new Contact())
            ->displayName('Jane Doe')
            ->phoneNumber('+98765432103')
            ->emailAdress('[email protected]')
            ->attribute('company', 'Acme Corp');
        
        return (new SMSMessage())
            ->text('Your order has been shipped!')
            ->toContact($contact);
    }
}

use Illuminate\Support\Facades\Notification;

Notification::send($user, new OrderNotification());
bash
   php artisan vendor:publish --tag="bird-config"