PHP code example of tallieutallieu / dry-sendcloud

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

    

tallieutallieu / dry-sendcloud example snippets




$app = new \Oak\Application();

$app->register([
    \Tnt\Sendcloud\SendcloudServiceProvider::class,
]);

$app->bootstrap();



try {
  $scParcel = $sendcloudApi->createParcel([
    'parcel' => [
      'order_numer' => '123',
      'name' => 'John Doe', // 'city' => 'Anytown', //  [ // Sendcloud\Model\Parcel();
$parcel->created = time();
$parcel->updated = time();
$parcel->sendcloud_id = $scParcel['id'];
$parcel->name = $scParcel['name'];
$parcel->address = $scParcel['address'];
$parcel->city = $scParcel['city'];
$parcel->postal_code = $scParcel['postal_code'];
$parcel->email = $scParcel['email'];
$parcel->tracking_number = $scParcel['tracking_number'];
$parcel->status = $scParcel['status']['id'];
$parcel->country = 'USA';
$parcel->is_return = $scParcel['is_return'];
$parcel->shipment_method = 1;
$parcel->save();

$label = new Tnt\Sendcloud\Model\Label();
$label->created = time();
$label->updated = time();
$label->label_printer = isset($scParcel['label']) ? $scParcel['label']['label_printer'] : '';
$label->normal_printer = isset($scParcel['label']) ? $scParcel['label']['normal_printer'] : [];
$label->save();

$parcel->label = $label;
$parcel->save();



$parcels = $sendcloudApi->getParcels();



$parcel = $sendcloudApi->getParcel(12345);



$shippingMethods = $sendcloudApi->getShippingMethods();



$labelContents = $sendcloudClient->download('12345');