(PHP Extension) Shopware Digest Authentication
Demonstrates using Digest access authentication for Shopware. For more information, see https://developers.shopware.com/developers-guide/rest-api/#digest-access-authentication
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new CkHttp();
// To use HTTP Digest Authentication, set the login and password, and also indicate that DigestAuth should be used.
$http->put_Login('api_username');
$http->put_Password('api_key');
$http->put_DigestAuth(true);
$sbResponseBody = new CkStringBuilder();
$success = $http->QuickGetSb('https://my-shopware-shop.com/api/articles?limit=2',$sbResponseBody);
if ($success == false) {
print $http->lastErrorText() . "\n";
exit;
}
$jResp = new CkJsonObject();
$jResp->LoadSb($sbResponseBody);
$jResp->put_EmitCompact(false);
print 'Response Body:' . "\n";
print $jResp->emit() . "\n";
?>
|