";
echo "
";
// Set the timezone to UTC for 1WorldSync API call
date_default_timezone_set("UTC");
$currentDateTime = new DateTime();
echo "Current DateTime: [".$currentDateTime->format('Y-m-d H:i:s')."]
";
$appID = "abcdef12"; // Please update with your APP ID here (8 characters)
echo "AppID: [".$appID."]
";
$secretKey = "abcdef12abcdef12abcdef12abcdef12"; // Please update with your Secret Key here (32 characters)
$gln = "0838016009225"; // Please update with your 13-digit GLN here (13 digits)
echo "GLN: [".$gln."]
";
$user = "bu.0838016009225.fv3Mwbk9"; // Please update with your BatchID here
echo "User: [".$user."]
";
$docID = "health-check-0838016009225-".$currentDateTime->format('Y-m-d\TH:i:s\Z');
echo "DocID: [".$docID."]
";
$dateStamp = $currentDateTime->format('Y-m-d\TH:i:s');
echo "DateStamp: [".$dateStamp."]
";
$timeStamp = $currentDateTime->format('Y-m-d\TH:i:s\Z');
$timeStampEnc = urlencode($timeStamp);
echo "TimeStampEnc: [".$timeStampEnc."]
";
$appIDEnc = urlencode($appID);
echo "AppIDEnc: [".$appIDEnc."]
";
$uri = "/feed/catrequest?app_id=".$appID."&TIMESTAMP=".$timeStamp;
$hash = hash_hmac('sha256', $uri, $secretKey, true);
$hashInBase64 = base64_encode($hash);
echo "HashBase64: [".$hashInBase64."]
";
$hashInBase64URIencoded = urlencode($hashInBase64);
echo "HashEnc: [".$hashInBase64URIencoded."]
";
echo "URL: [".'https://product-api.1worldsync.com/V1/feed/catrequest?app_id='.$appIDEnc.'&TIMESTAMP='.$timeStampEnc.'&hash_code='.$hashInBase64URIencoded."]
";
echo "
";
$curl = curl_init();
curl_setopt_array($curl,
array
(
CURLOPT_URL => 'https://product-api.1worldsync.com/V1/feed/catrequest?app_id='.$appIDEnc.'&TIMESTAMP='.$timeStampEnc.'&hash_code='.$hashInBase64URIencoded,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>
'
0838016009225
0838016009225
0838016003001
'.$docID.'
'.$dateStamp.'
0838016009225
bu.0838016009225.fv3Mwbk9
'.$docID.'
-
APPEND
10033200002137
0838016009225
US
health-check-0838016009225-2022-03-09T14:44:05.158Z
',
CURLOPT_HTTPHEADER =>
array
(
'Content-Type: application/xml',
'userGln: '.$gln,
'userId: '.$user
),
));
$response = curl_exec($curl);
curl_close($curl);
echo "API Response: [".$response."]
";
echo "
";
echo "End API Call
";
/*
Note:
This example does not explain the contents of the documents required to add/modify/publish documents.
This information can be found in the schema documentation from the Community Center at https://community.1worldsync.com/
Instead it shows the mechanism required to calculate the correct HMAC hash to complete the authentication handshack using this HMAC hash.
Production
----------
receiver : 0838016003001
endpoint : https://product-api.1worldsync.com/V1/feed/catrequest
envelope :
Pre-Production
---------------
receiver : 8380160030003
endpoint : https://product-api.preprod.1worldsync.com/V1/feed/catrequest
envelope :
Sample Request:
POST https://product-api.1worldsync.com/V1/feed/catrequest?app_id=35df93bc&TIMESTAMP=2024-01-02T21%3A45%3A46Z&hash_code=kGZoK9y9FRRYvwJCaAvCaftFdN5Zo%2FDQPyw45H8X6Vg%3D HTTP/1.1
Host: product-api.1worldsync.com
Content-Type: application/xml
userGln: 0838016009225
userId: bu.0838016009225.fv3Mwbk9
Content-Length: 1255
0838016009225
0838016009225
0838016003001
health-check-0838016009225-2024-01-02T21:45:46Z
2024-01-02T21:45:46
0838016009225
bu.0838016009225.fv3Mwbk9
health-check-0838016009225-2024-01-02T21:45:46Z
-
APPEND
10033200002137
0838016009225
US
health-check-0838016009225-2022-03-09T14:44:05.158Z
Sample Response:
{"data":{"responseMessage":"Request Accepted for processing. Please check the status of the request using the Response API with trackingId","trackingId":2245841},"serviceError":null,"status":200}
*/
?>