PHP code example of bernardinosousa / egoi-laravel

1. Go to this page and download the library: Download bernardinosousa/egoi-laravel 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/ */

    

bernardinosousa / egoi-laravel example snippets


use Bernardinosousa\EgoiLaravel\Facades\EgoiLaravel;

//Get All Contacts from List
try {
    $listId = 1;

    $contactListResponse = EgoiLaravel::api('contacts')->getAllContacts(
        $listId
    );

    dump($contactResponse);
} catch (\Exception $e) {
    dump('Exception when getting all contacts from list: ', $e->getMessage());
}

//Get Contact Information from List Id and Contact Id
try {
    $listId = 1;

    $contactId = "f51f0117ba";

    $contactResponse = EgoiLaravel::api('contacts')->getContact(
        $contactId, 
        $listId
    );

    dump($contactResponse);
} catch (\Exception $e) {
    dump('Exception when getting contact information: ', $e->getMessage());
}

//Create Contact from List
try {
    $contactBaseExtraPost = new \EgoiClient\EgoiModel\ContactBaseExtraPost([
        'base' => [
            "status" => "active",
            "first_name" => "John",
            "last_name" => "Doe",
            "birth_date" => "1975-01-10",
            "language" => "en",
            "email" => "[email protected]",
            //"cellphone" => "351-300404336",
            //"phone" => "351-300404336",
            "push_token_android" => [],
            "push_token_ios" => []
        ]
    ]);

    $listId = 1;

    $contactResponse = EgoiLaravel::api('contacts')->createContact(
        $listId, 
        $contactBaseExtraPost
    );

    dump($contactResponse);
} catch (\Exception $e) {
    dump('Exception when creating contact from list: ', $e->getMessage());
}

bash
php artisan vendor:publish --tag="egoi-laravel-config"