PHP code example of ham0mer / afdian

1. Go to this page and download the library: Download ham0mer/afdian library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ham0mer / afdian example snippets


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

$orders = $afdian->getAllOrders();
print_r($orders);

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

$sponsors = $afdian->getAllSponsors();
print_r($sponsors);

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

use \Ham0mer\Afdian\Login;
// 初始化 Login 对象
$client_id = "这里填写你的 Client ID";
$client_secret = "这里填写你的 Client Secret";
$siteurl = "这里填写你的网站地址";
$type = "tp"; // 填tp为ThinkPHP,填other为其他框架
$login = new Login($client_id,$client_secret,$siteurl,$type);

$login->login();
//返回信息
$login->callback($code,$state);