skygdi / shopify-private-app-foundation
此软件包的最新版本(dev-main)没有可用的许可证信息。
Shopify私有APP框架,安装并使用Shopiy Admin API令牌
dev-main
2021-05-19 04:09 UTC
Requires
- php: ^7.3|^8.0
- guzzlehttp/guzzle: ^7.3
- laravel/framework: ^8.12
This package is auto-updated.
Last update: 2024-09-19 11:15:57 UTC
README
设置
安装
composer require skygdi/shopify-private-app-foundation
APP设置
允许的重定向URL
https://your-app.ngrok.io/install
https://your-app.ngrok.io/install_authorize
修改.env文件
SHOPIFY_APP_API_KEY="APP_key"
SHOPIFY_APP_API_SECRET="APP_secret"
SHOPIFY_APP_API_SCOPES="read_products,read_product_listings,read_themes,write_themes,read_script_tags,write_script_tags"
构建逻辑控制器
入口URL为"/"。因此,您需要自己定义此路由。
use Skygdi\ShopifyPrivateAPPFoundation\Traits\ShopifyInstallTrait;
class HomeController extends Controller
{
use ShopifyInstallTrait; //Add
function entry(Request $request){
if( !$this->hashCheck($request) ) abort(403,"No Access Token Found");
//Hash check success, means it came from Shopify APP.
//Build your login code from here
//Auth::loginUsingId(1); //Like login a user or an admin backend.
//return redirect()->to('/admin');
}
}
更新Shopify框架的会话
config/session.php
'secure' => true
'same_site' => 'none'
用法
通过API令牌进行通信
$this->loadShopDomain();
$this->loadAccessToken();
//Do your REST API call