I have obtained access token and stored it in database after install the app goes to myapp page.
Lets say user has already installed the app and goes to my app . How can I get the shop name in my embedded app so I can get its accesstoken and perform requests.
Since the app already is in iframe and to get access token from database I have to use shop name but how can I get that in iframe ?
There is no good php api for detailed stuff support is good only for ruby on rails . I had figued this by checking there were iframe parameters but it good to be confident about things from a official person !
if (isset($_SERVER['HTTP_REFERER'])) {
$referalUrl = $_SERVER['HTTP_REFERER'];
$qs = parse_url($referalUrl, PHP_URL_QUERY);
if (!empty($qs)) {
parse_str($qs, $output);
print_r($output);
$shop = preg_replace('/.myshopify.com$/', '', $output['shop']); //get store name without fullurl
// TODO check for key existence
$_SESSION['shop'] = $shop;
}
}
This code will return shop name everytime you logged in. Hope this will help anyone. This code works for me.
$_SESSION['shop'] = $_GET['shop'];
works for first time only. When you logged in after logout, it doesnot return any value.