forked from firstdata/marketplace-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.php
20 lines (18 loc) · 797 Bytes
/
auth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$key = "XXXXXXXXXXXXXXXXXXXXXXX"; // Replace with API Secret from email
$username = "XXXXXXXXXXXXXXXXXX"; // Replace with API Username from email
$url = "XXXXXXXXXXXXXXXXXX"; // Replace with URL from email
$date = gmdate("r");
$stringToSign = 'date: ' . trim($date);
echo $encodedSignature = base64_encode(hash_hmac('sha1', $stringToSign, $key, true));
$hmacAuth = 'hmac username="' . $username . '",algorithm="hmac-sha1",headers="date",signature="' . $encodedSignature . '"';
return;
$headers = array(
'date: ' . $date,
'Authorization: ' . $hmacAuth,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . "/marketplace/v1/contracts/31/agreement");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$res = curl_exec($ch);
curl_close($ch);