linuxfront-v2-logistics/test.php
test.php is a developer sandbox script used to experiment with various shipping/logistics integrations, session debugging, and utility functions. It is not part of the production flow but serves as a proof-of-concept and QA tool.
Dependencies & Configuration
- inc/config.php
Loads environment constants (paths, credentials, e-mail addresses, etc.). - PHP Extensions:
- cURL (
curl_*) - SOAP (
SoapClient) - MySQLi (
mysqli_connect) - PHPMailer
- cURL (
include('inc/config.php');
ini_set('display_errors', -1);
ini_set('display_startup_errors', -1);
error_reporting(-1);
🛠️ Major Functional Sections
| Section | Purpose |
|---|---|
| Central Transport Quote 🛒 | JSON cURL POST to Central Transport quote API |
| Session Debug & Config 🧵 | Inspect PHP session ID and variables |
| Tech Logistics Rating Engine ⚙️ | XML cURL POST to internal rating engine |
| Direct Carrier Pickup 📦 | Dynamic include of carrier-specific pickup API script |
| Frontend Kendo UI Grid Demo 💻 | Commented-out Kendo UI grid example |
| Sample JSON Decode 📊 | Decode & print hard-coded JSON quote response |
| Estes Express SOAP Integration 🚚 | SOAP call to Estes Express RateQuoteService |
| Microsoft Graph OAuth Flow 🔒 | OAuth2 token exchange with Microsoft Identity Platform |
| PHPMailer Email Test 📧 | Send test e-mail via Office365 SMTP |
1. Central Transport Quote 🛒
Purpose: Test LTL quote retrieval from Central Transport’s JSON API.
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://client-api.centraltransport.com/api/v1/Quote/byClass',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
"accessCode" => "b34c94a1-b549-47b2-9592-f988bc07d",
"request" => [
"originZipCode" => "03055",
"destinationZipCode" => "03055",
"rateItems" => [
["id"=>1,"weight"=>450,"itemClass"=>"77.5","length"=>25,"width"=>25,"height"=>25],
["id"=>1,"weight"=>500,"itemClass"=>"60", "length"=>23,"width"=>23,"height"=>23]
],
"extraServices" => [
["accessorialKey"=>"notify"],
["accessorialKey"=>"hazmat"]
]
]
]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);
print_r(json_decode($response, true));
exit;
- Endpoint:
/api/v1/Quote/byClass - Key Fields:
accessCode,rateItems,extraServices
2. Session Debug & Config 🧵
Purpose: Dump session ID and contents for debugging.
echo 'front<br>';
echo 'Session ID: ' . session_id() . "<br>";
echo '<pre>'; print_r($_SESSION);
exit;
- Helps verify session handling and configuration constants.
3. Tech Logistics Rating Engine (XML) ⚙️
Purpose: Send an XML payload to the internal rating engine.
$URL = 'https://api.techlogistics.com/?v=1.1';
$xml = '<getratingenginequote>…</getratingenginequote>';
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Cache-Control: no-cache',
'Content-Type: application/xml'
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
$response = curl_exec($ch);
echo $response;
exit;
Highlights:
- Authentication via
<username>&<apikey>. <origin>and<destination>nodes for shipment routing.<shipmentitems>with dimensions, weight, NMFC, class.
4. Direct Carrier Pickup API 📦
Purpose: Dispatch to carrier-specific pickup logic.
$carrierId = $_REQUEST['carrier_id'];
include '/var/www/tech-portals/fawv2-tech-templates/rating_ltlquote_api_v1/direct_apis/pickup/'
. $carrierId . '_pickup_api.php';
exit;
- Drops into
…/pickup/{carrier_id}_pickup_api.php - Each file encapsulates that carrier’s pickup scheduling API.
5. Frontend Kendo UI Grid Demo 💻
Purpose: Prototype a data grid UI (commented out).
<!--
<div id="grid"></div>
<script>
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: { read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders" },
schema: { model: { fields: { OrderID:{type:"number"}, Freight:{type:"number"}, … } } },
pageSize: 20, serverPaging: true, serverFiltering: true, serverSorting: true
},
height: 550, filterable: true, sortable: true, pageable: true,
columns: [
{ field:"OrderID", filterable:false },
"Freight",
{ field:"OrderDate", title:"Order Date", format:"{0:MM/dd/yyyy}" },
{ field:"ShipName", title:"Ship Name" },
{ field:"ShipCity", title:"Ship City" }
]
});
});
</script>
-->
6. Sample JSON Decode 📊
Purpose: Decode a mock
EZRATE_RESULTand inspect it.
$json = '{ "EZRATE_RESULT": { "Products": [ … ], "Quotes": [ … ] } }';
$session_data = json_decode(str_replace("'", "", $json));
echo '<pre>'; print_r($session_data);
exit;
7. Estes Express SOAP Integration 🚚
Purpose: Consume Estes’s RateQuoteService via SOAP.
$soapURL = "https://www.estes-express.com/tools/rating/ratequote/v4.0/services/RateQuoteService?wsdl";
$client = new SoapClient($soapURL, ["trace"=>1, "soap_version"=>SOAP_1_1]);
$auth = ['user'=>'khamilton1','password'=>'Logist1cs!'];
$header = new SoapHeader('http://ws.estesexpress.com/ratequote','auth',$auth);
$client->__setSoapHeaders($header);
$rateRequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" …>…</soapenv:Envelope>';
try {
$response = $client->getQuote($rateRequest);
print_r($response);
} catch(Exception $e) {
echo '<pre>' . $e . '</pre>';
}
exit;
8. Microsoft Graph OAuth Flow 🔒
Purpose: Exchange an authorization code for tokens with Azure AD.
if ($_REQUEST['code']) {
$fields = [
'client_id' => $client_id,
'scope' => 'https://graph.microsoft.com/Team.ReadBasic.All',
'redirect_uri' => 'https://www.techlogistics.com/test.php',
'grant_type' => 'authorization_code',
'client_secret' => $client_secret,
'code' => $_REQUEST['code']
];
$ch = curl_init("https://login.microsoftonline.com/common/oauth2/v2.0/token");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded'],
CURLOPT_POSTFIELDS => http_build_query($fields),
CURLOPT_RETURNTRANSFER => true
]);
$response = json_decode(curl_exec($ch), true);
print_r($response);
exit;
}
- Supports refresh-token flow as well.
- Persists
access_token&refresh_tokeninto MySQL.
9. PHPMailer Email Test 📧
Purpose: Verify SMTP connectivity via Office 365.
require '/var/www/devtms/libs/sys_util/phpMailer/PHPMailerAutoload.php';
$mail = new PHPMailer(true);
$mail->Host = "smtp.office365.com";
$mail->Port = 587;
$mail->SMTPSecure = 'starttls';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "T3chTranz$18";
$mail->setFrom('[email protected]','invoicing');
$mail->addAddress('[email protected]','Imtiaz');
$mail->isHTML(true);
$mail->Subject = 'Here is the new invoicing email';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
if(!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
exit;
📝 Notes & Best Practices
- Isolation: Each test block ends with
exit;to prevent accidental execution of subsequent code. - Security: Credentials are hard-coded—consider environment variables or a vault.
- Maintainability: Split each integration into its own script for clarity.
- Cleanup: Remove unused or commented sections before committing to version control.