爱发电非官方简易 PHP SDK

Related tags

API afdian-php-sdk
Overview

afdian-php-sdk

爱发电非官方简易 PHP SDK by Akkariin

这是一个简单的 SDK,可以用于查询爱发电的订单和赞助者信息

Installation

将项目 clone 到本地即可

git clone https://github.com/ZeroDream-CN/afdian-php-sdk/ .

Examples

通过引入 afdian.php 即可调用相关函数

<?php
// 引入 SDK 核心文件
include(__DIR__ . "/afdian.php");

// 设定 User ID 和 Token
define("USERID", "这里改为你的 User ID");
define("TOKEN", "这里改为你的 Token");

// 初始化 Afdian 对象
$afdian = new Afdian(USERID, TOKEN);

检测 User ID 与 Token 是否有效,与服务器连接是否正常

echo sprintf("Ping status: %s\n", $afdian->pingServer() ? "Success" : "Failed");

获取所有的订单列表,并缓存到文件里,有效时间 120 秒

$orders = $afdian->getAllOrders(120, "order_cache.json");
print_r($orders);

在返回的订单列表里进一步查询,根据订单 ID 获取信息

$order = $afdian->getOrderById($orders, "这里写你的订单号");
print_r($order);

获取所有的赞助者,并缓存到 Redis,有效时间 600 秒

$sponsors = $afdian->getAllSponsors(600, "&redis=127.0.0.1:6379");
print_r($sponsors);

得到赞助者列表后,根据用户名查询赞助者信息

$user = $afdian->getSponsorByName($sponsors, "Lain音酱");
print_r($user);

另外也可以直接查看 afdian.php,每个方法都写了详细的注释。

Redis Cache

如需使用 Redis 缓存订单或赞助者信息,可以在 getAllOrders/getAllSponsors 的第二个参数填入以下格式内容:

&redis=服务器地址:端口

例如:

&redis=127.0.0.1:6379

Server Return

关于服务器返回的状态码以及更多信息,请查阅官方文档:

https://afdian.net/dashboard/dev

License

本项目使用 MIT 协议开源

About

本 SDK 非官方 SDK,可能有尚不完善的地方,欢迎通过 Issues 提出,或直接提交 PR。

You might also like...
PHP SDK - Flexie CRM fiskalizimi solution

PHP SDK - Flexie CRM fiskalizimi solution Fiskalizimi PHP SDK allows you to talk and generate your e-invoices programmatically from your own solution

PHP Digital Green Certificate SDK

Digital Green Certificate SDK PHP Indice Contesto Installazione Uso Licenza Dettaglio licenza Contesto Attenzione, questo repository è derivato dalle

Esse SDK em PHP foi desenvolvido no intuito de tornar mais prático a integração com nossa API.

Sobre Beedoo SDK Acessar documentação completa da Beedoo API. A API é organizada seguindo a arquitetura REST, boas práticas, convenções e padrões como

A PHP SDK for accessing the OpenAI GPT-3 API
A PHP SDK for accessing the OpenAI GPT-3 API

OpenAI GPT-3 Api Client in PHP Installation You can install the package via composer: composer require orhanerday/open-ai Usage use Orhanerday\OpenAi\

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login

Facebook SDK for PHP (v5) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

PHP SDK for the Sellix Developers API (developers.sellix.io)

PHP SDK for the Sellix Developers API (developers.sellix.io). Quickly get started and create products, payments and more using PHP.

Alibaba Cloud SDK for PHP

English | 简体中文 Alibaba Cloud SDK for PHP Alibaba Cloud SDK for PHP is a development kit that supports quick access to products, dependency on Alibaba

Aliyun OSS SDK for PHP

Alibaba Cloud OSS SDK for PHP README of Chinese Overview Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Clo

Qiniu Resource (Cloud) Storage SDK for PHP

Qiniu Cloud SDK for PHP 安装 推荐使用 composer 进行安装。可以使用 composer.json 声明依赖,或者运行下面的命令。SDK 包已经放到这里 qiniu/php-sdk 。 $ composer require qiniu/php-sdk 直接下载安装,SD

Owner
ZeroDream-CN
ZeroDream 零梦
ZeroDream-CN
Zoho CRM API SDK is a wrapper to Zoho CRM APIs. By using this sdk, user can build the application with ease

Archival Notice: This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refe

null 81 Nov 4, 2022
The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

Michelangelo van Dam 12 Dec 26, 2022
Facebook SDK for PHP (v6) - allows you to access the Facebook Platform from your PHP app

Facebook SDK for PHP (v6) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

null 0 Aug 10, 2022
Unofficial Firebase Admin SDK for PHP

Firebase Admin PHP SDK Table of Contents Overview Installation Documentation Support License Overview Firebase provides the tools and infrastructure y

kreait 1.9k Jan 3, 2023
Notion PHP SDK

Notion PHP SDK This is an unofficial PHP SDK for the new public Notion API. It's work in progress as we didn't get the change to be included to the pr

Codecycler 43 Nov 29, 2022
AWS Cognito package using the AWS SDK for PHP/Laravel

Laravel Package to manage Web and API authentication with AWS Cognito AWS Cognito package using the AWS SDK for PHP This package provides a simple way

EllaiSys 74 Nov 15, 2022
PHP SDK to interact with the Casper Network nodes via RPC

casper-php-sdk PHP SDK to interact with Casper Network nodes via RPC Install composer require make-software/casper-php-sdk Examples RPC Client: $node

MAKE Technology LLC 7 May 8, 2022
A Laravel 5+ (and 4) service provider for the AWS SDK for PHP

AWS Service Provider for Laravel 5/6/7/8 This is a simple Laravel service provider for making it easy to include the official AWS SDK for PHP in your

Amazon Web Services 1.5k Dec 28, 2022
A complete Notion SDK for PHP developers.

notion-sdk-php A complete Notion SDK for PHP developers. Installation composer require mariosimao/notion-php Getting started A Notion token will be n

Mario Simão 77 Nov 29, 2022
SDK of the LINE Login API for PHP

LINE Login for PHP SDK of the LINE Login API for PHP Documentation See the official API documentation for more information. Installation Use the packa

null 4 Sep 15, 2022