funmula / biggo-api-php-pms-client
BigGo API PMS PHP Client is a API written in PHP
Package info
github.com/Funmula-Corp/biggo-api-php-pms-client
pkg:composer/funmula/biggo-api-php-pms-client
v1.0.0
2023-07-19 06:34 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: >=7.4
README
🛒 BigGo PMS (Price Monitoring System) 的官方 PHP client,讓你用幾行程式碼就能存取平台、群組與歷史報表。
✨ Features
- 🔑 自動 token 管理 — 自動處理 OAuth2
client_credentials換發與過期續期 - 🏬 平台 / 群組 / 報表 — 完整存取 PMS 資源階層
- 📦 多格式下載 — 支援
csv/excel/json報表下載,可直接存檔 - 🧩 零相依 — 僅使用 PHP 內建的 cURL 與 JSON 擴充
📑 Table of Contents
🚀 Getting Started
📥 Installation
使用 composer:
composer require funmula/biggo-api-php-pms-client
🏗️ Initializing
先從 BigGo API 取得 client id 與 secret,再用以下程式碼建立 API 物件:
use Funmula\BiggoApiPhpPmsClient\BiggoPMSAPI; $api = new BiggoPMSAPI( '<Your client ID>', '<Your client secret>' );
💡 還沒有 client id / secret?請參考 👉 Funmula-Corp/guide
📡 Accessing BigGo PMS API
// 🏬 取得使用者可存取的平台列表 $platformList = $api->getPlatformList(); // 👥 取得平台內的群組列表 $groupList = $api->getGroupList('<Platform ID>'); // 📊 取得平台內的歷史報表列表 $reportList = $api->getReportList('<Platform ID>'); // 📥 取得報表內容,或直接存成檔案 $reportJson = $api->getReport('<Platform ID>', '<Report ID>', 'json');
📖 更多細節請參考 完整文件。
🧭 How It Works
🔐 認證流程:SDK 會在建立時自動換發 token,並在過期前自動續期。
sequenceDiagram
participant App as 🧑💻 Your App
participant SDK as 🐘 BiggoPMSAPI
participant Auth as 🔐 auth.biggo.com
participant API as 📡 api.biggo.com/pms
App->>SDK: new BiggoPMSAPI(clientID, clientSecret)
Note over SDK: token 不存在或已過期?
SDK->>Auth: POST /auth/v1/token (client_credentials)
Auth-->>SDK: access_token + expires_in
App->>SDK: getPlatformList()
SDK->>API: GET /platform (Bearer token)
API-->>SDK: 平台資料
SDK-->>App: array
Loading
🗂️ 資源階層:平台底下有群組,群組會產生報表,報表可下載成多種格式。
flowchart LR
A[🏬 Platform] --> B[👥 Group]
B --> C[📊 Report]
C --> D{📥 getReport}
D --> E[📄 CSV]
D --> F[📈 Excel]
D --> G[🔧 JSON]
Loading
📚 API Reference
| 方法 | 說明 | 回傳 |
|---|---|---|
getPlatformList() |
🏬 取得可存取的平台列表 | array |
getGroupList($platformID) |
👥 取得平台內的群組列表 | array |
getReportList($platformID, $options = []) |
📊 取得歷史報表列表 | array |
getReport($platformID, $reportID, $fileType, $saveAsFile = false, $filePath = '', $fileName = '') |
📥 下載報表(csv/excel/json) |
內容或檔案路徑 |
isTokenExpired() |
⏳ 檢查 token 是否過期 | bool |
getReportList 的 $options 可帶 size、in_sort、in_form、pms_groupid、start、end。