mochaka / laravel-erply
此包已被弃用且不再维护。未建议替代包。
Erply.com 的 Laravel 连接器
v1.0.2
2014-04-09 04:59 UTC
Requires
- php: >=5.3.0
- guzzlehttp/guzzle: 3.8.x
- illuminate/support: 4.1.*
This package is not auto-updated.
Last update: 2023-04-01 08:09:24 UTC
README
Laravel-Erply 是一个用于与 Erply.com API 交互的简单包。请阅读 http://erply.com/api 以了解有关有效 API 调用和参数的文档。
需求
- PHP 5.4+
- Laravel 4
- Guzzle 3
安装
将以下内容添加到您的 composer.json 文件中,并运行 composer upgrade
"mochaka/laravel-erply": "*"
将此行代码添加到您的 app/config/app.php 文件中的 providers 数组中
'Mochaka\Erply\ErplyServiceProvider',
您无需向您的 aliases 数组中添加任何内容,因为这个包会为您完成。
然后,您需要发布配置文件,并用您的 erply 凭据填写它。
php artisan config:publish mochaka/laravel-erply
使用方法
使用方法简单,您只需将 erply 网站的 API 调用作为函数,并将参数作为数组输入。
示例
如 API 的 PHP 示例 此处 所示,laravel-erply 包使操作变得更加简单。
$clientGroups = Erply::getClientGroups();
此调用将给出以下结果。一个 "responseStatus" 用来指示调用成功或失败,而 "recordsTotal" 则指示返回了多少条记录。
Array ( [status] => Array ( [request] => getCustomerGroups [requestUnixTime] => 1370507041 [responseStatus] => ok [errorCode] => 0 [generationTime] => 0.0026431083679199 [recordsTotal] => 3 [recordsInResponse] => 3 ) [records] => Array ( [0] => Array ( [clientGroupID] => 17 [customerGroupID] => 17 [parentID] => 0 [name] => Loyal Customers [pricelistID] => 0 [added] => 1283248838 [lastModified] => 1306833659 ) [1] => Array ( [clientGroupID] => 18 [customerGroupID] => 18 [parentID] => 0 [name] => One-time Customers [pricelistID] => 0 [added] => 1283248848 [lastModified] => 1306833655 ) [2] => Array ( [clientGroupID] => 20 [customerGroupID] => 20 [parentID] => 0 [name] => Campaign sign-ups [pricelistID] => 0 [added] => 1283248917 [lastModified] => 1306833695 ) ) )
数据可以通过正常数组访问
print $clientGroups['records'][0]['clientGroupID']; // 17