(PHP ActiveX) 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
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Http')
$http = new COM("Chilkat.Http");
// To use HTTP Digest Authentication, set the login and password, and also indicate that DigestAuth should be used.
$http->Login = 'api_username';
$http->Password = 'api_key';
$http->DigestAuth = 1;
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.StringBuilder')
$sbResponseBody = new COM("Chilkat.StringBuilder");
$success = $http->QuickGetSb('https://my-shopware-shop.com/api/articles?limit=2',$sbResponseBody);
if ($success == 0) {
print $http->LastErrorText . "\n";
exit;
}
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.JsonObject')
$jResp = new COM("Chilkat.JsonObject");
$jResp->LoadSb($sbResponseBody);
$jResp->EmitCompact = 0;
print 'Response Body:' . "\n";
print $jResp->emit() . "\n";
?>
|