codemojo / startkit
PHP应用程序的插件式组件服务
v0.1.940
2017-09-21 07:33 UTC
Requires
- php: >=5.2.0
- dev-master
- v0.1.940
- v0.1.939
- v0.1.938
- v0.1.937
- v0.1.936
- v0.1.935
- v0.1.934
- v0.1.933
- v0.1.932
- v0.1.931
- v0.1.93
- v0.1.92
- v0.1.91
- v0.1.90
- v0.1.89
- v0.1.88
- v0.1.87
- v0.1.86
- v0.1.85
- v0.1.84
- v0.1.83
- v0.1.82
- v0.1.81
- v0.1.71
- v0.1.54
- v0.1.53
- v0.1.52
- v0.1.51
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.2-alpha
- v0.1.1
- v0.1.1-alpha
- v0.1
- v0.1-alpha
This package is not auto-updated.
Last update: 2024-09-14 19:25:28 UTC
README
关于
欢迎来到CodeMojo SDK(启动开发工具包)。CodeMojo帮助您快速部署应用程序组件作为可插拔服务,以减少PHP应用程序的开发时间,提高生产力。
使用SDK非常简单直观。SDK包含以下四个主要服务
在此处下载PHP SDK
在此处下载示例应用程序
查看Wiki以获取更多文档信息
查看仪表板使用说明以了解如何使用仪表板
安装与使用
库存/纯PHP
下载SDK并将autoload.php
包含到您的源代码中
Composer
只需将以下内容添加到您的composer.json
{ "require": { "codemojo/startkit": "0.1.*" } }
示例
一旦您在CodeMojo仪表板中启用并配置了忠诚度模块,您就可以像以下示例那样简单使用它。有关仪表板的更多文档信息。
require_once '../sdk/autoload.php'; const CLIENT_ID = 'sample@codemojo.io'; const CLIENT_SECRET = 'PLB6DHP7VcykRDdvloi2X9tEq3FvsIBhtdn7UdeQ'; // Create an instance of Authentication Service $authService = new AuthenticationService(CLIENT_ID, CLIENT_SECRET, Endpoints::LOCAL, function($type, $message){ switch($type){ case Exceptions::AUTHENTICATION_EXCEPTION: echo 'Authentication Exception'; break; case Exceptions::BALANCE_EXHAUSTED_EXCEPTION: echo 'Low balance'; break; case Exceptions::FIELDS_MISSING_EXCEPTION: echo 'Fields missing'; break; case Exceptions::QUOTA_EXCEPTION: echo 'Quota Exhausted Exception'; break; case Exceptions::TOKEN_EXCEPTION: echo 'Invalid token Exception'; break; default: echo 'Error ' . $message; break; } }); // Create an instance of Loyalty Service - If you have more than one wallet service, // you can optionally pass in the wallet instance as the second argument $loyaltyService = new LoyaltyService($authService); // Credit points to user - You can have different set of rules based on the platform // For example, you can promote your android app by saying Get 5% more cashback when you transact through the Android app $status = $loyaltyService->addLoyaltyPoints("user1@codemojo.io", 1500, "android", "", 7, "Cashback for Order no. 1231"); // Get the balance in the wallet $balance = $loyaltyService->getBalance("user1@codemojo.io"); // Check how much maximum can be redeemed by the user for the given (current) transaction value // Again, you can have different set of rules for redemption based on the platform $maximumRedemption = $loyaltyService->maximumRedemption("user1@codemojo.io",8500); // Redeem amount // (user_id, redemption_amount, current_transaction_value, platform) $loyaltyService->redeem("user1@codemojo.io", 500, 8500, "android");
有关每个服务可用方法和参数的更多详细信息,请参阅各个服务页面。