Api
3 years ago
Integrations
3 years ago
StorageDriver
4 years ago
Url
3 years ago
data
6 years ago
Api.php
3 years ago
Backlog.php
4 years ago
BacklogReplayTimeoutException.php
4 years ago
ChallengeProcessingException.php
4 years ago
ChallengeVerificationException.php
4 years ago
ConfigFetcherException.php
4 years ago
Crypto.php
3 years ago
Device.php
6 years ago
DeviceType.php
6 years ago
ElementRevision.php
3 years ago
EmptyConfigException.php
6 years ago
FileHandle.php
5 years ago
Filesystem.php
4 years ago
HealthStatus.php
5 years ago
IntegrationUrl.php
6 years ago
NitroPack.php
3 years ago
NoConfigException.php
5 years ago
Pagecache.php
2 years ago
PurgeType.php
3 years ago
ServiceDownException.php
5 years ago
StorageException.php
6 years ago
VariationCookieException.php
5 years ago
WebhookException.php
5 years ago
Website.php
6 years ago
IntegrationUrl.php
38 lines
| 1 | <?php |
| 2 | namespace NitroPack\SDK; |
| 3 | |
| 4 | class IntegrationUrl { |
| 5 | const INTEGRATION_BASE = 'https://nitropack.io/integration/'; |
| 6 | private $path; |
| 7 | |
| 8 | public function __construct($widget, $siteId, $siteSecret, $version = null, $additional_params = array()) { |
| 9 | $timestamp = time(); |
| 10 | $query = array( |
| 11 | "site_id" => $siteId, |
| 12 | "timestamp" => $timestamp, |
| 13 | ); |
| 14 | $nonce = $this->getNonce($query, $siteSecret); |
| 15 | $query["nonce"] = $nonce; |
| 16 | |
| 17 | if ($version !== null) { |
| 18 | $query["ver"] = $version; |
| 19 | } |
| 20 | |
| 21 | $query = array_merge($query, $additional_params); |
| 22 | |
| 23 | $this->path = $widget . "?" . http_build_query($query); |
| 24 | } |
| 25 | |
| 26 | public function getNonce($query, $secret) { |
| 27 | return hash_hmac("sha256", http_build_query($query), $secret); |
| 28 | } |
| 29 | |
| 30 | public function getUrl() { |
| 31 | return self::INTEGRATION_BASE . $this->path; |
| 32 | } |
| 33 | |
| 34 | public function getPath() { |
| 35 | return $this->path; |
| 36 | } |
| 37 | } |
| 38 |