arslaniftikhar/shopify-client
Composer 安装命令:
composer require arslaniftikhar/shopify-client
包简介
Shopify API client for PHP
README 文档
README
A simple Shopify PHP SDK for private apps to easily interact with the Shopify API.
Shopify API Documentation | Packagist
Package has following features:
- ability to easily GET, PUT, POST and DELETE resources
Setup/Installation
Uses arslaniftikhar/curl.
You need to include this library by running:
composer require arslaniftikhar/curl 1.0
Public App
First of all, you must have set up the public app. View documentation. You need an authorization URL.
$shopify = new Shopify($shop, $APP_API_KEY, $APP_SECRET); $client->installURL($permissions, $redirect_uri, $auto_redirect = true);
At this point, the user is taken to their store to authorize the application to use their information.
If the user accepts, they are taken to the redirect URL.
session_start(); $shopify = new Shopify($_GET['shop'], $APP_API_KEY, $APP_SECRET); if ($token = $client->getAccessToken()) { // You can save the access token to database to make the api call in future. $_SESSION['shopify_access_token'] = $token; $_SESSION['shopify_shop_domain'] = $_GET['shop']; // Redirect to app's dashboard URL header("Location: dashboard.php"); } else { die('Couldn't find the access token'); }
It's at this point, in dashboard.php you could starting doing API request by setting the access_token.
session_start(); $shopify = new Shopify(, $APP_API_KEY, $APP_SECRET); $shopify->setAccessToken($_SESSION['shopify_access_token']); // you can get the resource by just passing the resource name. $products = $shopify->get('products');
Methods
GET
Get resource information from the API.
$shopify = new Shopify($SHOPIFY_SHOP_DOMAIN, $SHOPIFY_API_KEY, $SHOPIFY_SHARED_SECRET); $result = $shopify->get('shop');
$result is a JSON decoded array:
Get product IDs by passing query params:
$result = $shopify->get('products', ['query' => ['fields' => 'id']]); foreach($result->products as $product) { print $product->id; }
POST
Create new content with a POST request.
$data = ['product' => ['title' => 'my new product']]; $result = $shopify->post('products', $data);
PUT
Update existing content with a given ID.
$data = ['product' => ['title' => 'updated product name']]; $result = $shopify->put('products/' . $product_id, $data);
DELETE
Easily delete resources with a given ID.
$shopify->delete('products/' . $product_id);
arslaniftikhar/shopify-client 适用场景与选型建议
arslaniftikhar/shopify-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 arslaniftikhar/shopify-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arslaniftikhar/shopify-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-18