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\Contacts\ContactManager;

$contacts = ContactManager::get(); // Retrieve all contacts with default settings

$contact = ContactManager::get('contact-id');

$contacts = ContactManager::get(null, 20, true, 'nextPageToken');

use Media101\Bird\Services\Contacts\BirdContact;
use Media101\Bird\Services\Contacts\ContactManager;

$contact = (new BirdContact())
    ->name('John Doe')
    ->phone('+12345678901')
    ->email('[email protected]');

$response = ContactManager::createOrUpdate($contact);

$response = ContactManager::createOrUpdate($contact, 'emailaddress');

$response = ContactManager::delete('contact-id');

namespace App\Notifications;

use Media101\Bird\Services\Contacts\BirdContact;
use Media101\Bird\Services\Notifications\SMS\SMSMessage;

class OrderReceived
{

    public function __construct(
        private string $content
    ) {}
    
    public function via($notifiable): array
    {
        return [SMSChannel::class];
    }

    public function toSMS(User $notifiable): array
    {
        // The phone number must have a country code appended.
        $contact = (new BirdContact())->phone($notifiable->phone_number);
        
        return (new SMSMessage())
            ->to($contact)
            ->type(SMSType::TEXT)
            ->text($this->content);
    }
    
}

$user->notify(new OrderReceived('Your order has been received'));
bash
php artisan vendor:publish --tag="bird-config"