1. Go to this page and download the library: Download shipbg/php-sdk 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/ */
shipbg / php-sdk example snippets
use ShipBG\Sdk\Client;
$client = new Client('YOUR_API_TOKEN'); // default CurlTransport
// or inject a platform transport:
// $client = new Client($token, 'https://shipbg.com/api/v1', new MyWpRemoteTransport());
$account = $client->account->show(); // GET /account → AccountResponseData
$rates = $client->rates->quote([ // POST /rates:quote → QuoteRatesResult
'from_address' => [/* ... */],
'to_address' => [/* ... */],
'parcel' => ['weight' => 1.5],
'currency' => 'BGN',
]);
foreach ($rates->rates as $rate) {
// typed DTO graph
}
final class WpRemoteTransport implements \ShipBG\Sdk\Transport
{
public function send(string $method, string $url, array $headers, ?string $body): array
{
$res = wp_remote_request($url, ['method' => $method, 'headers' => $headers, 'body' => $body]);
return [(int) wp_remote_retrieve_response_code($res), (string) wp_remote_retrieve_body($res)];
}
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.