breakpoint/etsy-php
Composer 安装命令:
composer require breakpoint/etsy-php
包简介
PHP wrapper for the Etsy api.
README 文档
README
This library aims to provide an easy way to access all methods of the Etsy API. The structure is based on the organization of the Etsy API documentation. Methods are organized based upon their "Type" such as Listing, User, etc.
Table of Contents
Quick Start
Install via Composer by running:
composer require breakpoint/etsy-php
Usage to access all featured listings:
$esty = new \breakpoint\etsy\EtsyClient('your-keystring', 'your-secret'); $results = $etsy->listing->findAllFeaturedListings(); foreach ($results as $item) { echo $item->listing_id; }
Requests
All requests originate with the EtsyClient object and are referenced as properties. These generally correspond to the Etsy API documentation with some variations. Three additional types are included but not documented: application, baseline and server. These are only referenced by results from the getMethodTable method.
$etsy->listing-> // method found in API documentation
Parameters
Parameters are specified using an array passes directly into the method you are performing.
$etsy->listing->getListing(['listing_id' => '123abc']);
Fields
If you wish to specify fields to be returned then specify them first as an array.
$etsy->listing->fields(['listing_id', 'title', 'description', 'url'])->getListing(['listing_id' => '123abc']);
Associations
Etsy allows you to request additional Associations be returned with your request. You must specify these first as an array.
$etsy->shop->associations(['Listings' => [ 'scope' => 'draft', 'limit' => 10, 'offset' => 0, 'select' => array('listing_id', 'title'), // you can also specify sub-associations //'associations' => // scope, limit, select, etc ]]) ->getShop(['shop_id' => '123abc']);
Data
All PATCH, POST and PUT requests also accept an array of data.
$etsy->userprofile->updateUserProfile( // first array is parameters ['user_id', 'user_123'], // second array is data you are changing ['first_name' => 'john', 'last_name' => 'developer']);
Results
The POST method will always return an EtsyObject as the response. The GET method will return either a EtsyResults or EtsyObject based on how many items are expected to be returned. If you are fetching a listing then an EtsyObject will be returned while if you are fetching active listings then EtsyResults will be returned.
All other requests (PUT, PATCH, DELETE) will return a true or false depending upon their response.
Note: return values have been generated automatically then manually reviewed. Please create an issue or pull request if value is not as expected.
EtsyResults
The EtsyResults object is a simple iterable and array accessible collection. All items within the collection are instances of EtsyObject. A few basic methods are available:
$results = $etsy->listing->findAllFeaturedListings(); $results[0]; // access the item at that position $results->count(); // returns number of items $results->first(); // access the first item $results->add(object); // useful if you are performing requests with multiple pages
EtsyObject
This simple object allows you to access the individual results as properties via magic methods.
$listing = $etsy->listing->getListing(['listing_id' => 'listing_123']); echo $listing->title; echo $listing->getType(); // 'Listing'
OAuth Requests
All methods which require a permission scope will need oauth access via an access and secret token. An easy way to generate these is by using y0lk/oauth1-etsy. You'll specify these values when creating the EtsyClient object.
$esty = new \breakpoint\etsy\EtsyClient('your-keystring', 'your-secret', 'access_token', 'token_secret');
Provisional Users
By default, only the user who owns the application can authenticate and use it via oauth. To allow other users to use your application you must either request "full access" via the Etsy developers site or by adding them as provisional users. This is made possible by two included method calls:
$etsy->application->addProvisional(['user_id' => 'user_123']); $etsy->application->removeProvisional(['user_id' => 'user_123']); // returns all users with access $etsy->application->getProvisional();
Advanced
If you prefer to receive the full response then use the raw() function on your request.
$raw = $etsy->listing->raw()->getTrendingListings();
Development
The generate.php file is included which creates resources based upon all known types returned from the API. This is meant to serve as a starting point when major changes are made to the API.
php generate.php
breakpoint/etsy-php 适用场景与选型建议
breakpoint/etsy-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 140 次下载、GitHub Stars 达 7, 最近一次更新时间为 2021 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 breakpoint/etsy-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 breakpoint/etsy-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 140
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-17