Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6259d8b

Browse files
Merge pull request #307 from anikghosh256/master
feat: add getEmbeddedAppUrl method
2 parents 284d7c8 + 82c0406 commit 6259d8b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎lib/ShopifySDK.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,28 @@ public static function getApiUrl() {
421421
return self::$config['ApiUrl'];
422422
}
423423

424+
/**
425+
* Returns the appropriate URL for the host that should load the embedded app.
426+
*
427+
* @param string $host The host value received from Shopify
428+
*
429+
* @return string
430+
*/
431+
public static function getEmbeddedAppUrl($host)
432+
{
433+
if (empty($host)) {
434+
throw new SdkException("Host value cannot be empty");
435+
}
436+
437+
$decodedHost = base64_decode($host, true);
438+
if (!$decodedHost) {
439+
throw new SdkException("Host was not a valid base64 string");
440+
}
441+
442+
$apiKey = self::$config['ApiKey'];
443+
return "https://$decodedHost/apps/$apiKey";
444+
}
445+
424446
/**
425447
* Maintain maximum 2 calls per second to the API
426448
*

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /