PHP code example of mysendingbox / mysendingbox-php

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

    

mysendingbox / mysendingbox-php example snippets





rovide an API Key in the class constructor
// in order to instantiate the Mysendingbox object
$apiKey = 'your API Key here';
$mysendingbox = new \Mysendingbox\Mysendingbox($apiKey);

$to_address = array(
  'name'                  => 'Mysendingbox',
  'address_line1'         => '30 rue de rivoli',
  'address_line2'         => '',
  'address_city'          => 'Paris',
  'address_country'       => 'France',
  'address_postalcode'    => '75004'
);

$letter = $mysendingbox->letters()->create(array(
  'to'                  => $to_address,
  'source_file'         => '@test.pdf',
  'description'         => 'Test Letters',
  'color'               => 'bw',
  'source_file_type'    => 'file',
  'postage_type'        => 'verte'
));

print_r($letter);



Key = 'your API key here';
$mysendingbox = new \Mysendingbox\Mysendingbox($apiKey);

$to_address_electronic = array(
  'first_name'            => 'Erlich',
  'last_name'             => 'Dumas',
  'company'               => 'Mysendingbox',
  'email'                 => '[email protected]'
);

$letter = $mysendingbox->letters()->createElectronic(array(
  'to'                  => $to_address_electronic,
  'source_file'         => '<html>This is the electronic letter attached document</html>',
  'source_file_type'    => 'html',
  'description'         => 'Test Electronic Letters',
  'content'             => 'Please review the attached documents',
  'postage_type'        => 'lre'
));

print_r($letter);



  endingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890');

  $letters = $mysendingbox->letters()->all();

  print_r($letters);


  endingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890');

  $letter = $mysendingbox->letters()->get('LETTER_ID');

  print_r($letter);


rovide an API Key in the class constructor
// in order to instantiate the Mysendingbox object
$mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890');

$account = $mysendingbox->accounts()->create(array(
  'email'               => "[email protected]",
  'name'                => "Erlich Bachman",
  'phone'               => "+33104050607",
  'company_name'        => "MSB Partner from PHP Wrapper",
  'address_line1'       => '30 rue de rivoli',
  'address_line2'       => '',
  'address_city'        => 'Paris',
  'address_country'     => 'France',
  'address_postalcode'  => '75004'
));

print_r($account);



rovide an API Key in the class constructor
// in order to instantiate the Mysendingbox object
$mysendingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890');

$account_response = $mysendingbox->accounts()->updateEmail("COMPANY_ID_HERE", "[email protected]");


  endingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890');

  $letters = $mysendingbox->invoices()->all();

  print_r($letters);


  endingbox = new \Mysendingbox\Mysendingbox('test_12345678901234567890');

  $letter = $mysendingbox->invoices()->get('INVOICE_ID');

  print_r($letter);
bash
// Install Composer
curl -sS https://getcomposer.org/installer | php

// Add Mysendingbox.fr PHP client as a dependency
composer