I need After-ship API integration for e-commerce website.

https://www.aftership.com/docs/api/4

which will be useful in tracking the order status.

I have downloaded sdk from

https://github.com/abishekrsrikaanth/aftership-php-sdk

I have given the api key in AfterShip/Core/request.php.

But its not working can anyone suggest me steps to integrate it.

Dani AI

Generated

A focused troubleshooting checklist and a minimal debugging workflow to make the AfterShip PHP SDK reveal what's going wrong (ties together 's setup and ' suggestion to call the SDK's "all" method).

Enable diagnostics first: enable full PHP error reporting and check the webserver/PHP error log; confirm the PHP cURL and OpenSSL extensions are installed and enabled; verify the API key is active in the AfterShip dashboard and contains no extra whitespace. Prefer passing the API key at runtime (constructor or env var) rather than hardcoding it in library core files — that keeps the key obvious and avoids accidental commits.

Isolate SDK vs network problems: check whether the SDK exposes an all() method (as noted) or uses a different method name. Capture the raw SDK return value and inspect it (it may be a JSON string, an array, or an object). If the SDK returns nothing, try a direct HTTP call from the server (or enable cURL verbose) to rule out firewall/proxy/TLS issues. Also check for PHP version incompatibilities if the SDK is old — older libraries sometimes break on modern PHP.

Example debug pattern (use Composer autoload where available; adapt paths if not):

<?php
// require 'vendor/autoload.php'; // use Composer autoload if installed

error_reporting(E_ALL);
ini_set('display_errors', 1);

use AfterShip\Couriers;

// create client with real API key string (do not commit this)
$client = new Couriers('MY_ACTUAL_API_KEY');

// call whichever method exists and capture raw response
$method = method_exists($client, 'all') ? 'all' : (method_exists($client, 'get') ? 'get' : null);

$response = $method ? $client->{$method}() : null;

// write raw dump to a log for inspection
file_put_contents('/tmp/aftership_debug.txt', var_export($response, true) . PHP_EOL, FILE_APPEND);

// if response is JSON text, decode and check for errors
if (is_string($response)) {
    $decoded = json_decode($response, true);
    file_put_contents('/tmp/aftership_debug.txt', "json_err: " . json_last_error_msg() . PHP_EOL . var_export($decoded, true), FILE_APPEND);
}

Additional notes: inspect the SDK's Request class to see how it sets headers and the API key; a mismatch there is a common cause. Temporary TLS verification disabling can reveal certificate problems (only for debugging). If the SDK proves brittle or unmaintained, a small direct REST wrapper using curl or Guzzle is a reliable fallback.

Recommended Answers

All 4 Replies

please Help me out with this issue

Create a new Request instance about and call the all() method.

I tried , but i am not getting response

<?php 
require 'Core/Request.php';
require 'Couriers.php';
$courier = new AfterShip\Couriers('API-KEY');
$response = $courier->get();

echo $response;
?>

Did you use your own API key? Check if the object is valid, then check what exactly is in the reponse. Any errors in your error log?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.