-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: let php developer easier to access kwaixiaodian api
- Loading branch information
Showing
18 changed files
with
667 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea/ | ||
.git/ | ||
runtime/ | ||
vendor/ | ||
.env | ||
.DS_Store | ||
*.lock | ||
*.cache | ||
.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'@Symfony' => true, | ||
'@DoctrineAnnotation' => true, | ||
'@PhpCsFixer' => true, | ||
'array_syntax' => [ | ||
'syntax' => 'short' | ||
], | ||
'list_syntax' => [ | ||
'syntax' => 'short' | ||
], | ||
'concat_space' => [ | ||
'spacing' => 'one' | ||
], | ||
'blank_line_before_statement' => [ | ||
'statements' => [ | ||
'declare', | ||
], | ||
], | ||
'general_phpdoc_annotation_remove' => [ | ||
'annotations' => [ | ||
'author' | ||
], | ||
], | ||
'ordered_imports' => [ | ||
'imports_order' => [ | ||
'class', 'function', 'const', | ||
], | ||
'sort_algorithm' => 'alpha', | ||
], | ||
'single_line_comment_style' => [ | ||
'comment_types' => [ | ||
], | ||
], | ||
'yoda_style' => [ | ||
'always_move_variable' => false, | ||
'equal' => false, | ||
'identical' => false, | ||
], | ||
'phpdoc_align' => [ | ||
'align' => 'left', | ||
], | ||
'multiline_whitespace_before_semicolons' => [ | ||
'strategy' => 'no_multi_line', | ||
], | ||
'constant_case' => [ | ||
'case' => 'lower', | ||
], | ||
'global_namespace_import' => [ | ||
'import_classes' => true, | ||
'import_constants' => true, | ||
'import_functions' => null, | ||
], | ||
'class_attributes_separation' => true, | ||
'combine_consecutive_unsets' => true, | ||
'declare_strict_types' => true, | ||
'linebreak_after_opening_tag' => true, | ||
'lowercase_static_reference' => true, | ||
'no_useless_else' => true, | ||
'no_unused_imports' => true, | ||
'not_operator_with_successor_space' => true, | ||
'not_operator_with_space' => false, | ||
'ordered_class_elements' => true, | ||
'php_unit_strict' => false, | ||
'phpdoc_separation' => false, | ||
'single_quote' => true, | ||
'standardize_not_equals' => true, | ||
'multiline_comment_opening_closing' => true, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('runtime') | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
) | ||
->setUsingCache(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# kwaixiaodian-sdk | ||
# kwaixiaodian-sdk | ||
|
||
let php developer easier to access kwaixiaodian api | ||
|
||
Install the latest version with | ||
|
||
```bash | ||
$ composer require ydg/kwaixiaodian-sdk" | ||
``` | ||
## Basic Usage | ||
```php | ||
<?php | ||
use Ydg\KwaixiaodianSdk\Kwaixiaodian; | ||
$app = new Kwaixiaodian([ | ||
'app_key' => 'your app_key', | ||
'app_secret' => 'your app_secret', | ||
'sign_secret' => 'your sign_secret', | ||
'access_token' => 'your access_token', | ||
'http' => [ // set default options to http client | ||
'headers' => [ | ||
'Content-Type' => 'application/x-www-form-urlencoded', | ||
'Accept' => 'application/json;charset=UTF-8', | ||
], | ||
] | ||
]); | ||
$app->user->openUserInfoGet(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Dotenv\Dotenv; | ||
use Dotenv\Repository\Adapter; | ||
use Dotenv\Repository\RepositoryBuilder; | ||
|
||
! defined('BASE_PATH') && define('BASE_PATH', __DIR__); | ||
|
||
require_once BASE_PATH . '/vendor/autoload.php'; | ||
|
||
if (file_exists(BASE_PATH . '/.env')) { | ||
$repository = RepositoryBuilder::createWithNoAdapters() | ||
->addAdapter(Adapter\PutenvAdapter::class) | ||
->immutable() | ||
->make(); | ||
|
||
Dotenv::create($repository, [BASE_PATH])->load(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "ydg/kwaixiaodian-sdk", | ||
"description": "Easier to create a sdk", | ||
"license": "MIT", | ||
"keywords": [ | ||
"php", | ||
"sdk", | ||
"kwai", | ||
"kwaixiaodian", | ||
"kwaixiaodian-sdk" | ||
], | ||
"require": { | ||
"php": "^7.0|^8.0", | ||
"ydg/foudation-sdk": "^1.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3.12", | ||
"phpunit/phpunit": "^9.5", | ||
"vlucas/phpdotenv": "^5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Ydg\\KwaixiaodianSdk\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"YdgTest\\KwaixiaodianSdk\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"sort-packages": true | ||
}, | ||
"scripts": { | ||
"test": "phpunit", | ||
"cs-fix": "php-cs-fixer fix ." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="./bootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Tests"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ydg\KwaixiaodianSdk\Api\Distribution; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Ydg\KwaixiaodianSdk\KwaixiaodianApi; | ||
|
||
/** | ||
* @method openDistributionCpsKwaimoneyPidCreate(array $params) // 创建快赚客推广位 | ||
* @method openDistributionCpsKwaimoneyPidUpdate(array $params) // 更新快赚客推广位 | ||
* @method openDistributionCpsKwaimoneyPidList(array $params) // 查询快赚客推广位 | ||
* @method openDistributionCpsKwaimoneyLinkCreate(array $params) // 创建快赚客推广链接 | ||
* @method openDistributionCpsKwaimoneySelectionItemList(array $params) // 获取站外分销商品列表 | ||
* @method openDistributionCpsKwaimoneySelectionItemDetail(array $params) // 获取站外分销商品详情 | ||
* @method openDistributionCpsKwaimoneyOrderList(array $params) // 查询快赚客分销订单 | ||
* @method openDistributionCpsKwaimoneyNewPromotionEffectDetail(array $params) // 查询快赚客拉新推广效果数据明细 | ||
*/ | ||
class Distribution extends KwaixiaodianApi | ||
{ | ||
/** | ||
* 站外分销快赚客订单详情查询 | ||
* @link https://open.kwaixiaodian.com/docs/api?apiName=open.distribution.cps.kwaimoney.order.detail&categoryId=46&version=1 | ||
* @param array|int|string $oid | ||
* @return array | ||
* @throws GuzzleException | ||
*/ | ||
public function openDistributionCpsKwaimoneyOrderDetail($oid): array | ||
{ | ||
$oid = is_array($oid) ? $oid : [$oid]; | ||
return $this->get('open.distribution.cps.kwaimoney.order.detail', [ | ||
'oid' => implode(',', $oid), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ydg\KwaixiaodianSdk\Api\Distribution; | ||
|
||
use Pimple\Container; | ||
use Pimple\ServiceProviderInterface; | ||
|
||
class ServiceProvider implements ServiceProviderInterface | ||
{ | ||
/** | ||
* Registers services on the given container. | ||
* | ||
* This method should only be used to configure services and parameters. | ||
* It should not get services. | ||
*/ | ||
public function register(Container $pimple) | ||
{ | ||
$pimple['distribution'] = function ($pimple) { | ||
return new Distribution(isset($pimple['config']) ? $pimple['config']->toArray() : []); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ydg\KwaixiaodianSdk\Api\User; | ||
|
||
use Pimple\Container; | ||
use Pimple\ServiceProviderInterface; | ||
|
||
class ServiceProvider implements ServiceProviderInterface | ||
{ | ||
/** | ||
* Registers services on the given container. | ||
* | ||
* This method should only be used to configure services and parameters. | ||
* It should not get services. | ||
*/ | ||
public function register(Container $pimple) | ||
{ | ||
$pimple['user'] = function ($pimple) { | ||
return new User(isset($pimple['config']) ? $pimple['config']->toArray() : []); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Ydg\KwaixiaodianSdk\Api\User; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Ydg\KwaixiaodianSdk\KwaixiaodianApi; | ||
|
||
class User extends KwaixiaodianApi | ||
{ | ||
/** | ||
* 获取用户公开信息 | ||
* @link https://open.kwaixiaodian.com/docs/api?apiName=open.user.info.get&categoryId=46&version=1 | ||
* @throws GuzzleException | ||
*/ | ||
public function openUserInfoGet(): array | ||
{ | ||
return $this->get('open.user.info.get'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ydg\KwaixiaodianSdk; | ||
|
||
use Ydg\FoudationSdk\ServiceContainer; | ||
|
||
/** | ||
* @property Api\Distribution\Distribution $distribution | ||
* @property Api\User\User $user | ||
*/ | ||
class Kwaixiaodian extends ServiceContainer | ||
{ | ||
protected $providers = [ | ||
Api\Distribution\ServiceProvider::class, | ||
Api\User\ServiceProvider::class, | ||
]; | ||
} |
Oops, something went wrong.