ghostzero/bitinflow-accounts

该软件包已被废弃,不再维护。作者建议使用 bitinflow/accounts 软件包。

Laravel 5+ 的 PHP bitinflow Accounts API 客户端

3.2.4 2023-09-01 22:20 UTC

This package is auto-updated.

Last update: 2023-09-01 22:21:11 UTC


README

Total Downloads Latest Stable Version License Discord

Laravel 5+ 的 PHP bitinflow Accounts API 客户端

目录

  1. 安装
  2. 事件监听器
  3. 配置
  4. 示例
  5. 文档
  6. 开发

安装

composer require ghostzero/bitinflow-accounts

如果您使用 Laravel 5.5+,则已完成,否则继续。

将服务提供者添加到您的 app.php 配置文件中

Bitinflow\Accounts\Providers\BitinflowAccountsServiceProvider::class,

事件监听器

  • SocialiteProviders\Manager\SocialiteWasCalled 事件添加到您的 app/Providers/EventServiceProvider 中的 listen[] 数组。
  • 将您的监听器(即来自提供者的监听器)添加到您刚刚创建的 SocialiteProviders\Manager\SocialiteWasCalled[]
  • 为该提供者添加的监听器是 'GhostZero\\BitinflowAccounts\\Socialite\\BitinflowExtendSocialite@handle',
  • 注意:除非您使用自己的提供者覆盖它们,否则您不需要为内置的社交提供者添加任何内容。
/**
 * The event handler mappings for the application.
 *
 * @var array
 */
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // add your listeners (aka providers) here
        'Bitinflow\\Accounts\\Socialite\\BitinflowExtendSocialite@handle',
    ],
];

配置

将配置复制到配置文件夹

$ php artisan vendor:publish --provider="Bitinflow\Accounts\Providers\BitinflowAccountsServiceProvider"

将环境变量添加到您的 .env

BITINFLOW_ACCOUNTS_KEY=
BITINFLOW_ACCOUNTS_SECRET=
BITINFLOW_ACCOUNTS_REDIRECT_URI=https://

您需要在服务配置文件中添加一个条目,以便在配置文件缓存用于生产环境(Laravel 命令 artisan config:cache)之后,所有配置仍然可用。

添加到 config/services.php

'bitinflow-accounts' => [
    'client_id' => env('BITINFLOW_ACCOUNTS_KEY'),
    'client_secret' => env('BITINFLOW_ACCOUNTS_SECRET'),
    'redirect' => env('BITINFLOW_ACCOUNTS_REDIRECT_URI')
],

示例

基本

$bitinflowAccounts = new Bitinflow\Accounts\BitinflowAccounts();

$bitinflowAccounts->setClientId('abc123');

// Get SSH Key by User ID
$result = $bitinflowAccounts->getSshKeysByUserId(38);

// Check, if the query was successfull
if ( ! $result->success()) {
    die('Ooops: ' . $result->error());
}

// Shift result to get single key data
$sshKey = $result->shift();

echo $sshKey->name;

设置器

$bitinflowAccounts = new Bitinflow\Accounts\BitinflowAccounts();

$bitinflowAccounts->setClientId('abc123');
$bitinflowAccounts->setClientSecret('abc456');
$bitinflowAccounts->setToken('abcdef123456');

$bitinflowAccounts = $bitinflowAccounts->withClientId('abc123');
$bitinflowAccounts = $bitinflowAccounts->withClientSecret('abc123');
$bitinflowAccounts = $bitinflowAccounts->withToken('abcdef123456');

OAuth 令牌

$bitinflowAccounts = new Bitinflow\Accounts\BitinflowAccounts();

$bitinflowAccounts->setClientId('abc123');
$bitinflowAccounts->setToken('abcdef123456');

$result = $bitinflowAccounts->getAuthedUser();

$user = $userResult->shift();
$bitinflowAccounts->setToken('uvwxyz456789');

$result = $bitinflowAccounts->getAuthedUser();
$result = $bitinflowAccounts->withToken('uvwxyz456789')->getAuthedUser();

外观

use Bitinflow\Accounts\Facades\BitinflowAccounts;

BitinflowAccounts::withClientId('abc123')->withToken('abcdef123456')->getAuthedUser();

文档

Oauth

public function retrievingToken(string $grantType, array $attributes)

支付意向

public function getPaymentIntent(string $id)
public function createPaymentIntent(array $parameters)

SSH 密钥

public function getSshKeysByUserId(int $id)
public function createSshKey(string $publicKey, string $name = NULL)
public function deleteSshKey(int $id)

用户

public function getAuthedUser()
public function createUser(array $parameters)

OAuth 范围枚举

开发

运行测试

composer test
BASE_URL=xxxx CLIENT_ID=xxxx CLIENT_KEY=yyyy CLIENT_ACCESS_TOKEN=zzzz composer test

生成文档

composer docs

加入 bitinflow Discord!

Discord