jketelaar/php-fut-api

允许您使用PHP与FUT交互

0.0.6 2017-03-16 10:58 UTC

README

Build Status Build Status

完美的PHP FUT API

这是一个完美的FUT AP...
别急,让我们先回答一个问题。

你是EA的员工吗?
是:这没什么,只是离开...
否:太好了!欢迎来到完美的PHP FUT API 😏

如何安装?

使用Composer安装此项目;composer require jketelaar/php-fut-api

然后可以使用类似以下方式开始使用API:

<?php
require_once('vendor/autoload.php');

define('DATA_DIR', __DIR__ . '/data/');

$api = new \JKetelaar\fut\api\API('your@email.me', 'password', 'secret', 'totp_callback', 'platform');

// You can also disable the SSL verify peer, when you're having issues with your environment. Simply pass true as the latest parameter
// $api = new \JKetelaar\fut\api\API('your@email.me', 'password', 'secret', 'totp_callback', 'platform', true); 

if($api->login() === true) {
    echo('We\'re logged in!' . "\n");

    $handler = $api->getHandler();
    foreach($handler->getTradepile() as $trade) {
        // Interact with $trade here
    }
}

function totp_callback() {
    $totp = new \OTPHP\TOTP('FIFA', 'SECRET');

    return $totp->now();
}

常见问题解答

枚举(eration)是如何工作的?

正如你可能看到的,我们正在使用php-enum的实现,因此我们可以在类中提供枚举,并进行类型提示。
一个例子是类ChemistryStyle

使用几个常量,你可以访问变量,但也可以用它们进行类型提示。
比如说你有一个

class ChemistryStyle extends Enum  {
    const BASIC = 250;
    const SNIPER = 251;
}

现在我们可以通过以下方式获取常量的值:ChemistryStyle::BASIC

但在更高级的水平上,我们也可以使用它们进行类型提示,使用括号。
比如说我们有这个函数

function findByChemistryStyle(ChemistryStyle $style){
    echo('Searching for players with style ID' . $style);
}

正如你所看到的,我们有一个参数,它只允许ChemistryStyle。
我们可以通过在常量后面添加一个开括号和一个闭括号来调用这个函数

findByChemistryStyle(ChemistryStyle::SNIPER())

致谢