每週二 YT 直播 Q&A(可 Discord Call-in)
YT:https://www.youtube.com/@codelove_tw
DC:https://discord.gg/fvCF2whZ9D

⭐️ Shopify 技術教練(給工程師)
https://job.turn.tw/developer-coaching

⭐️ Shopify 接案服務(給品牌)
https://job.turn.tw/shopify-services

⭐️ 台灣 Shopify 開發者 LINE 群(非官方)
https://line.me/ti/g2/YUasX5K3CJ4QdIx76zppjHlh3-q8w-xkSyK1LA
登入次數:856 次
註冊於2022年11月28日
  發表了 471 篇貼文
  新增了 1,218 則留言
  貼文共 860,632 次瀏覽
近期留言

實驗一下非嵌入式 shopify app 的串接流程

找 AI 寫的最簡單串接 不確定流程是否為 best practice ``` <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; class ShopifyController extends Controller { public function index(Request $request) { // Shopify 必定傳入 shop=xxxxx.myshopify.com $shop = $request->query('shop'); if (!$shop) { return 'Missing ?shop=xxxxx.myshopify.com'; } // 從 DB 找現有 token (POC 用 session 模擬) $token = session("token_{$shop}"); // 已安裝 → 直接進入 app 面板 if ($token) { return "已安裝 App,商店 {$shop} 的 Token 是:<br>".$token; } // 尚未安裝 → 跳 OAuth Flow $clientId = '6b7001530576df226f1e8d6773eea438'; $scopes = 'read_products'; // $redirectUri = route('shopify.redirect'); $redirectUri = 'https://demo-connect.turn.tw/redirect'; $authorizeUrl = "https://{$shop}/admin/oauth/authorize?".http_build_query([ 'client_id' => $clientId, 'scope' => $scopes, 'redirect_uri' => $redirectUri, ]); return redirect($authorizeUrl); } public function redirect(Request $request) { $shop = $request->get('shop'); $code = $request->get('code'); if (!$shop || !$code) { return 'Missing shop or code.'; } $clientId = '6b7001530576df226f1e8d6773eea438'; $clientSecret = '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'; // 呼叫 Shopify 換永久 access token $response = Http::post("https://{$shop}/admin/oauth/access_token", [ 'client_id' => $clientId, 'client_secret' => $clientSecret, 'code' => $code, ]); if ($response->failed()) { return 'Token exchange failed: '.$response->body(); } $accessToken = $response->json('access_token'); // POC → 先存在 Session session(["token_{$shop}" => $accessToken]); return redirect('/?shop='.$shop); } } ```


shopify 突然宣布 2026 將不再允許新增 custom app,這也太倉促了吧

一下 client id + client secret 一下 api key + api secret 是在哭? 答案其實很簡單: 🧨 Shopify 內部團隊 → 不同部門搞兩種說法 1️⃣ Developer Dashboard(Platform 團隊) 負責 App 資料、App 建立流程 → 他們遵循 OAuth 2.0 標準用語 → 就叫 Client ID / Client Secret 這是「平台管理後台」那邊的人在開發。 2️⃣ App SDK / API(Shopify API 團隊) 負責 Node / Remix / Ruby / PHP SDK → 早期從 2016 就用 API key / API secret → 文件 & SDK 也都是這樣稱呼 → 如果硬改會: 破壞所有舊專案 破壞所有 NPM package 破壞所有教學內容 破壞所有 sample apps 所以 SDK 團隊堅持 繼續用 apiKey / apiSecretKey。