Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/ShopifySDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,28 @@ public static function getApiUrl() {
return self::$config['ApiUrl'];
}

/**
* Returns the appropriate URL for the host that should load the embedded app.
*
* @param string $host The host value received from Shopify
*
* @return string
*/
public static function getEmbeddedAppUrl($host)
{
if (empty($host)) {
throw new SdkException("Host value cannot be empty");
}

$decodedHost = base64_decode($host, true);
if (!$decodedHost) {
throw new SdkException("Host was not a valid base64 string");
}

$apiKey = self::$config['ApiKey'];
return "https://$decodedHost/apps/$apiKey";
}

/**
* Maintain maximum 2 calls per second to the API
*
Expand Down