PHP code example of dibmartins / locaweb

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

    

dibmartins / locaweb example snippets


try{

     = new \Locaweb\Api('https://api.smtplw.com.br/v1/', 'your_auth_token');

    $message = new \Locaweb\Message($api);

    $response = $message->post([
        'headers' => ['Content-Type': 'text/plain'], // 'text/html' para body em html
        'subject' => "qualquer titulo",
        'body'    => "qualquer corpo",
        'from'    => "[email protected]",
        'to'      => "[email protected]",
        'cc'      => ['[email protected]', '[email protected]'],
        'bcc'     => ['[email protected]', '[email protected]']
    ]);

    var_dump($response);
}
catch(\Locaweb\Exception $e){
    
    var_dump($e);
}

try{

     = new \Locaweb\Api('https://api.smtplw.com.br/v1/', 'your_auth_token');

    $message = new \Locaweb\Message($api);

    $hoje = new \DateTime();

    $response = $message->get([
        'status'     => 'all',
        'start_date' => $hoje->format('Y-m-d'),
        'end_date'   => $hoje->format('Y-m-d'),
        'page'       => 1,
        'per'        => 100
    ]);

    var_dump($response);
}
catch(\Locaweb\Exception $e){
    
    var_dump($e);
}

try{

     = new \Locaweb\Api('https://api.smtplw.com.br/v1/', 'your_auth_token');

    $message = new \Locaweb\Message($api);

    $response = $message->getById(37764);

    var_dump($response);
}
catch(\Locaweb\Exception $e){
    
    var_dump($e);
}