iaretedd/fortnite-api

PHP 封装官方 Fortnite API。

0.0.13 2019-06-04 17:21 UTC

This package is auto-updated.

Last update: 2024-09-05 04:27:15 UTC


README

使用 PHP 与官方 Fortnite API 交互。

Packagist Packagist

安装

使用 composer 引入项目: composer require iaretedd/fortnite-api

用法

创建一个基本测试脚本以确保一切安装正确

<?php

require_once 'vendor/autoload.php';

use Fortnite\Auth;
use Fortnite\Account;
use Fortnite\Mode;
use Fortnite\Language;
use Fortnite\Platform;

// Authenticate
$auth = Auth::login('epic_email@domain.com','password');

// Output each stat for all applicable platforms
var_dump($auth->profile->stats);

// Grab someone's stats
$sandy = $auth->profile->stats->lookup('sandalzrevenge');
echo 'Sandy Ravage has won ' . $sandy->pc->solo->wins . ' solo games and ' . $sandy->pc->squad->wins . ' squad games!';

朋友

$auth = Auth::login('epic_email@domain.com','password');

// Get list of friends
// Params:
//  - boolean $includePending If set to false, friend requests will be removed from output.
var_dump($auth->profile->getFriends());

// Add user to a friendlist
// Params:
// - string $accountId Account Id of a user that you're going to add
$auth->profile->addFriend($accountId);

// Remove user from a friendlist
// Params:
// - string $accountId Account Id of a user that you're going to remove
// Returns int 204 on success
$successfullyRemoved = $auth->profile->removeFriend($accountId) === 204;

获取排行榜

$auth = Auth::login('epic_email@domain.com','password');
var_dump($auth->leaderboard->get(Platform::PC, Mode::DUO)); 

获取新闻

$auth = Auth::login('epic_email@domain.com','password');
var_dump($auth->news->get(News::BATTLEROYALE, Language::ENGLISH)); 

获取商店

$auth = Auth::login('epic_email@domain.com','password');
var_dump($auth->store->get(Language::ENGLISH)); 

获取挑战

$auth = Auth::login('epic_email@domain.com','password');
// All weekly challenges
var_dump($auth->profile->challenges->getWeeklys()); 

// Or just get a specific week (in this example, week 1)
var_dump($auth->profile->challenges->getWeekly(1)); 

常量

Platform [ PC, PS4, XB1 ]

Mode [ SOLO, DUO, SQUAD ]

Language [ ENGLISH, GERMAN, SPANISH, CHINESE, FRENCH, ITALIAN, JAPANESE ]

News [ BATTLEROYALE, SAVETHEWORLD ]

贡献

Fortnite 在较新版本的 Windows 客户端中现在使用 SSL 证书固定。我建议使用 iOS 移动应用程序来进行任何未来的 API 反向工程,因为 Windows 客户端的作弊保护使去除证书固定变得困难。如果 iOS 版本添加了 SSL 证书固定,我可以轻松提供补丁来移除它,因为 iOS 版本不包含任何反作弊软件。