"; $queueName = ""; $sharedAccessKeyName = ""; $sharedAccessKey = ""; /* example */ /* $namespace = "gc-tenantname-business-data-servicebus"; $queueName = "xx-orders-queue"; $sharedAccessKeyName = "QueueListen"; $sharedAccessKey = "Vftest7tdYLKpVlLM3Q7ZeQGg94PMuRYmGW+ASbGdOxVk="; */ /* CONFIG END, APP CODE */ function generateSasToken($namespace, $queueName, $sharedAccessKeyName, $sharedAccessKey, $expiryInSeconds = 3600) { $uri = strtolower(urlencode("https://$namespace.servicebus.windows.net/$queueName")); $expiry = time() + $expiryInSeconds; $stringToSign = $uri . "\n" . $expiry; $signature = base64_encode(hash_hmac('sha256', $stringToSign, $sharedAccessKey, true)); $token = sprintf( 'SharedAccessSignature sr=%s&sig=%s&se=%d&skn=%s', $uri, urlencode($signature), $expiry, $sharedAccessKeyName ); return $token; } $sasToken = generateSasToken($namespace, $queueName, $sharedAccessKeyName, $sharedAccessKey); function getOrderFromQueue($learnMode, $namespace, $queueName, $sasToken) { $endpoint = "https://$namespace.servicebus.windows.net/$queueName/messages/head"; $headers = [ "Authorization: $sasToken", "Content-Type: application/json", "Accept: application/json" ]; if (!$learnMode) { $ch = curl_init($endpoint); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); $err = curl_errno($ch); $response = curl_exec($ch); } else { $response = '{"delivery":{"deliveryType":null,"deliveryName":null,"deliveryCost":null,"firstname":null,"lastname":null,"street":null,"house":null,"flat":null,"city":null,"postcode":null,"countryCode":null,"phone":null,"email":null,"comments":null},"deliveryBranch":{"id":null},"deliveryWorkshop":{"id":null},"erpParams":{"branch":"undefined","documentType":"undefined","documentName":null,"paymentType":"undefined","paymentName":null,"transportType":"OWN","transportName":"Afhalen bij uw Depot","voucher":"","bookingMethod":""},"recipient":{"B2B2C":"B2B","B2B2BNumber":"9900000","B2B2BName":"PartsCom","businessId":"12345","firstname":"Bart","lastname":"Simpson","companyName":"YoYoYo ","street":"Streetowska 25","house":null,"flat":null,"city":"Washington","postcode":"7541AN","countryCode":"IR","nip":"548123123123","phone":"00123456789","email":"parts@part*.eu"},"payment":{"paymentType":null,"paymentName":null,"paymentDone":null,"externalPaymentId":"6423c35a05e94b488cd1abcd4720da4"},"user":{"userName":"parts@part*.eu","displayName":"Truck and Sons"},"dateOfCreation":"2024-01-16T09:00:58.137","dateOfOrder":"2024-01-16T09:12:26.49","sellingValue":45.10,"toBePaidValue":45.10,"businessOrderId":"2024/01/000022","plateNumber":"GB12345","comments":null,"items":[{"Id":"D06710","businessId":"CU 3132","index":null,"name":null,"quantity":1.0,"priceNet":9.78,"priceGross":9.78,"priceWithoutCoreNet":9.78,"priceWithoutCoreGross":9.78,"corePriceNet":0.00,"corePriceGross":0.00,"sellingValueNet":9.78,"sellingValueGross":9.78,"vatValue":0.00,"vat":0.0000,"price":9.78,"corePrice":0.00,"sellingValue":9.78},{"Id":"E58950","businessId":"432 901 253 2","index":null,"name":null,"quantity":1.0,"priceNet":35.32,"priceGross":35.32,"priceWithoutCoreNet":35.32,"priceWithoutCoreGross":35.32,"corePriceNet":0.00,"corePriceGross":0.00,"sellingValueNet":35.32,"sellingValueGross":35.32,"vatValue":0.00,"vat":0.0000,"price":35.32,"corePrice":0.00,"sellingValue":35.32}]}'; $httpCode = 200; $err = 0; } if ($err) { echo 'Error: ' . curl_error($err); } else { if (!$learnMode) { $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); } if ($httpCode == 200) { $orderData = json_decode($response, true); } elseif ($httpCode == 204) { echo "Message queue is empty\n"; } else { echo "HTTP Error: $httpCode\n"; } } if (!$learnMode) curl_close($ch); return $orderData; } /* APP CODE END, YOUR CODE START */ $orderData = getOrderFromQueue($learnMode, $namespace, $queueName, $sasToken); var_dump($orderData);