App reviews, troubleshooting, and recommendations
Hi, i am able to create a custom app, but unable to install it on development store and our Shopify account as well.
from development store my URL look like this(https://XXXXX/sku-shopify2/?hmac=8622fc2033172237bf7c1afd1c8598e2e23313b3262e9b3f10dd072c9bd12ffe&sh... )
I am attaching my install.php and generate.php(redirect url)
install.php
<?php
$shop = $_GET['shop'];
$api_key = "2f17b4c22649532380d95490cf17673e";
$scopes = "read_orders,write_orders,read_products,write_products";
$redirect_uri = "https://XXXXX/sku-shopify2/generate_token.php";
// Build install/approval URL to redirect to
$install_url = "https://" . $shop . ".myshopify.com/admin/oauth/authorize?client_id=" . $api_key . "&scope=" . $scopes . "&redirect_uri=" . urlencode($redirect_uri);
// Redirect
header("Location: " . $install_url);
die();
generate.php
<?php
// Get our helper functions
require_once("inc/functions.php");
$api_key = "2f17b4c22649532380d95490cf17673e";
$shared_secret = "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";
$params = $_GET; // Retrieve all request parameters
$hmac = $_GET['hmac']; // Retrieve HMAC request parameter
$params = array_diff_key($params, array('hmac' => '')); // Remove hmac from params
ksort($params); // Sort params lexographically
$computed_hmac = hash_hmac('sha256', http_build_query($params), $shared_secret);
// Use hmac data to check that the response is from Shopify or not
if (hash_equals($hmac, $computed_hmac)) {
// Set variables for our request
$query = array(
"client_id" => $api_key, // Your API key
"client_secret" => $shared_secret, // Your app credentials (secret key)
"code" => $params['code'] // Grab the access key from the URL
);
// Generate access token URL
$access_token_url = "https://" . $params['shop'] . "/admin/oauth/access_token";
// Configure curl client and execute request
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $access_token_url);
curl_setopt($ch, CURLOPT_POST, count($query));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));
$result = curl_exec($ch);
curl_close($ch);
// Store the access token
$result = json_decode($result, true);
echo $access_token = $result['access_token'];
} else {
// Someone is trying to be shady!
die('This request is NOT from Shopify!');
}
Explore the 30-30-30 rule, a dynamic social media strategy for new businesses. Learn how t...
By Trevor Sep 20, 2023Discover how to leverage the often overlooked footer of your ecommerce site to gain custom...
By Skye Sep 15, 2023In this blog, we’ll be shining a light on Shopify Partners, Experts, and Affiliates. Who a...
By Imogen Sep 13, 2023