Giter Site home page Giter Site logo

php-fut-api's Introduction

Build Status Build Status

The perfect PHP FUT API

This is a perfect FUT AP...
No wait, let's first answer a question.

Are you an EA employee?
Y: This is nothing, just leave...
N: Great! Welcome to the perfect PHP FUT API 😏

How to install?

Install this project using Composer; composer require jketelaar/php-fut-api.

Then start using the API using something like:

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

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

$api = new \JKetelaar\fut\api\API('[email protected]', '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('[email protected]', '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();
}

FAQ

How do the enum(eration)s work?

As you might have seen, we're using an implemententation of php-enum, so we could provide enumerations within classes and type hinting.
An example of this is the class ChemistryStyle.

With a few constants, you can access the variables, but also use them for type hinting.
Let's say you have:

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

Now we can get the values of the constants, by doing: ChemistryStyle::BASIC.

But in a more advanced level, we can also use these for type hinting, using parenthesises.
Say we have the function:

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

As you can see, we have a parameter, which only allows ChemistryStyle.
We can call this function using the constant and adding an opening-and-closing parenthesis:

findByChemistryStyle(ChemistryStyle::SNIPER())

Credits

php-fut-api's People

Contributors

albvadi avatar jketelaar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-fut-api's Issues

Current ToDo's

We currently have a few things to be done, so feel free to contribute:

  • Fix the Hasher
  • Remove TOTP requirement
  • Create a proper Composer project from this (so composer require jketelaar/php-fut-bot can be used)

Error code: 281658

ERROR:
Fatal error: Uncaught JKetelaar\fut\api\errors\login\MainLogin: Unable to login with unknown response With the following message: Page not matching login form page () With error code: 281658 in C:\xampp\htdocs\rangos\src\JKetelaar\fut\api\user\Login.php:352 Stack trace: #0 C:\xampp\htdocs\rangos\src\JKetelaar\fut\api\user\Login.php(96): JKetelaar\fut\api\user\Login->postLoginForm('https://signin....') #1 C:\xampp\htdocs\rangos\src\JKetelaar\fut\api\API.php(123): JKetelaar\fut\api\user\Login->login() #2 C:\xampp\htdocs\rangos\prueba2.php(8): JKetelaar\fut\api\API->login() #3 {main} thrown in C:\xampp\htdocs\rangos\src\JKetelaar\fut\api\user\Login.php on line 352

CODE:

$api = new \JKetelaar\fut\api\API('[email protected]', 'XXX', 'XXX', 'email_callback', 'ps4', true);

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

function email_callback() {
    return '84505842';
}

I'm running this code on localhost/Xampp. Installed this plugin with composer.
Thanks in advance :)

SSL Certificate Problem

Hi, trying to use the API, I get the following error:

Fatal error: Uncaught JKetelaar\fut\api\errors\login\MainLogin: Unable to login with unknown response With the following message: Peer certificate cannot be authenticated with given CA certificates: SSL certificate problem: unable to get local issuer certificate With error code: 60 in C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\user\Login.php:110 Stack trace: #0 C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\user\Login.php(90): JKetelaar\fut\api\user\Login->requestMain() #1 C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\API.php(114): JKetelaar\fut\api\user\Login->login() #2 C:\xampp_7\htdocs\fut17\index.php(8): JKetelaar\fut\api\API->login() #3 {main} thrown in C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\user\Login.php on line 110

Adding $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); in /vendor/jketelaar/php-fut-api/src/JKetelaar/fut/api/user/Login.php in setupCurl() solves the problem, but, maybe it´s not the best way...

Thanks!

Search for starting price and/or buy price

How to search for starting price and/or buy now price. They are not in the Parameter.php.

class Parameter extends ImprovedEnum {
    const LEAGUE               = 'leag';
    const CHEMISTRY_STYLE      = 'playStyle';
    const TEAM                 = 'team';
    const MIN_BUY              = 'minb';
    const MAX_BUY              = 'maxb';
    const MIN_BID              = 'micr';
    const MAX_BID              = 'macr';
    const DEFINITION_ID        = 'definitionId';
    const MASKED_DEFINITION_ID = 'maskedDefId';
    const LEVEL                = 'lev';
    const ZONE                 = 'zone';
    const POSITION             = 'pos';
}

So i want the array of all players with staringPrice X and buyNowPrice X.

unexpected '.', expecting '

I got this error:
Parse error: syntax error, unexpected '.', expecting ')
On this line:
/src/JKetelaar/fut/api/API.php on line 118

How to fix it?

Write tests for login

Write tests for login and let Travis test these every so-what-hours.
This will notice me/us on time, instead of users figuring out their errors.

How to access players sent to the tradepile?

I am trying to get the PlayerIDs (not the MaskedID or ResourceId as EA call it) of all the players that I sent to the tradepile. I managed to get the ResourceId of each card but how do I access the getBaseId() from the Player Class from here?

This is my current code:

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

    $handler = $api->getHandler();
    foreach($handler->getTradepile() as $trade => $value) {
    	if ($value->getItemData()->getItemType() == "player") {
    		
			echo $value->getItemData()->getResourceId()."<br />";

    	}
    }   
}

Error with certificate on login

I'm getting an error while I'm trying to login
Message: Unable to login with unknown response With the following message: Peer certificate cannot be authenticated with given CA certificates: SSL certificate problem: unable to get local issuer certificate
With error code: 60

Smart tutorial

Hello,

I am very interested about your project, and I am ready to help you test and to propose improvements .. but I don't know how use the BOT.. is a bit new for me with this system node. exe

Can you give us a more detailed tutorial?

Thank you

Login mobile-companion

Hey,

Thanks for your great stuff, it's pretty cool to use it. Btw, it should be nice to implements connection with mobile api, so we could login with when we get temporary banned with webapp connection.

Thx again & great job !

PS: I'll try to do some pull requests soon, I have some idea to improve a little bit this tool

How to use the API?

Please someone help me, tell me how to login? It should be run on a server and displayed on browser right? Other programs needed? (Already installed with composer).

Could someone share some code?

UPDATE: solved by changing PHP version.

get TradeID

How to get the TradeID of an active player auction?

Search for players

I'am doing something wrong right?

if($api->login() === true) {
    $searcher = $api->getHandler()->getSearcher();
    $players = $searcher->searchFor(\JKetelaar\fut\api\market\items\ItemType::PLAYER(), [], 0, 50);
    echo $players;
}

No error's but only echo the word array.

SBCs

Since now we are able to complete SBCs via the web-app it will be great to be able to auto-complete SBCs like the GOLD UPGRADE SBC. Like select some random 75-78 non rare cards and submit them.

Use the same instance API on multiple pages.

Is it possible to use the same API instance, storing it in some way?

I'm trying to store the int within _SESSION, but failed.

Will I have to log in to the API instance for each page?

$api = new \JKetelaar\fut\api\API(
    $creds[ 'username' ], $creds[ 'password' ], $creds[ 'secret' ], $creds[ 'key' ], $creds[ 'platform' ]
);
   
$api->login();
     
$_SESSION['API'] = $api;

List Item function

I am trying to list a player from my tradepile but with no success and I see there is no item listing function included. I suppose that's has something to do with sendRequestion().

This is the request the item listing function needs to make

POST /ut/game/fifa17/auctionhouse HTTP/1.1
Host: utas.external.s3.fut.ea.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Firefox/51.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Cookie: cookie
DNT: 1
Connection: keep-alive
Referer: https://www.easports.com/iframe/fut17/bundles/futweb/web/flash/FifaUltimateTeam.swf?cl=165353
Content-type: application/json
Accept: application/json
X-UT-PHISHING-TOKEN: token
X-UT-SID: id
X-UT-Embed-Error: true
X-HTTP-Method-Override: POST
Content-length: 84
{"startingBid":300,"duration":3600,"itemData":{"id":4444444444},"buyNowPrice":350}

Function to relist tradepile?

Hi everyone,

i've used another API, which isn't working anymore unfortunately :(
So, I thought I could this API a try. I browsed a little through the source code, but couldn't find a method to relist the whole tradepile. Is there any or am I just too blind to see it?

[ERROR 295712] Incorrect verification code

Hi, trying to use the APi, I get the following error:
Fatal error: Uncaught JKetelaar\fut\api\errors\login\MainLogin: Unable to login with unknown response With the following message: Incorrect verification code With error code: 295712 in C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\user\Login.php:377 Stack trace: #0 C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\user\Login.php(94): JKetelaar\fut\api\user\Login->postTwoFactorForm('https://signin....') #1 C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\API.php(114): JKetelaar\fut\api\user\Login->login() #2 C:\xampp_7\htdocs\fut17\index.php(8): JKetelaar\fut\api\API->login() #3 {main} thrown in C:\xampp_7\htdocs\fut17\vendor\jketelaar\php-fut-api\src\JKetelaar\fut\api\user\Login.php on line 377

Using the example in the readme, I´m changing:

  • [email protected] --> My correct email
  • password --> My account password
  • secret --> My answer to the security question
  • totp_callback --> Don´t change
  • platform --> 'ps4'
  • SECRET (in totp_callback function) --> My answer to the security question

It´s this correct??
Each time I try the login and get the error, I receive an email with the security code

Thanks!!

Fatal Error when calling $handler->getTradepile()

It started 3 hours ago.
$handler = $api->getHandler();
foreach($handler->getTradepile() as $trade) {
// Interact with $trade here
}
will result in
Fatal error: Uncaught exception 'BadMethodCallException' with message 'No static method or enum constant '_DEFAULT' in class JKetelaar\fut\api\market\items\ItemType' in C:\xampp\htdocs\ea\vendor\myclabs\php-enum\src\Enum.php:184 Stack trace: #0 C:\xampp\htdocs\ea\src\JKetelaar\fut\api\ImprovedEnum.php(33): MyCLabs\Enum\Enum::__callStatic('_DEFAULT', Array) #1 C:\xampp\htdocs\ea\src\JKetelaar\fut\api\ImprovedEnum.php(33): JKetelaar\fut\api\ImprovedEnum::_DEFAULT() #2 C:\xampp\htdocs\ea\src\JKetelaar\fut\api\market\trading\ItemData.php(141): JKetelaar\fut\api\ImprovedEnum::findByKey('gkCoach', true) #3 C:\xampp\htdocs\ea\src\JKetelaar\fut\api\market\trading\Trade.php(125): JKetelaar\fut\api\market\trading\ItemData::toObject(Array) #4 C:\xampp\htdocs\ea\src\JKetelaar\fut\api\market\Handler.php(144): JKetelaar\fut\api\market\trading\Trade::toObject(Array) #5 C:\xampp\htdocs\ea\sell.php(16): JKetelaar\fut\api\market\Handler->getTradepile() #6 {main} thrown in C:\xampp\htdocs\ea\vendor\myclabs\php-enum\src\Enum.php on line 184

Any clues?

Invalid Verification Code

Fatal error: Uncaught exception 'JKetelaar\fut\api\errors\login\MainLogin' with message 'Unable to login with unknown response With the following message: Incorrect verification code With error code: 295712' in C:\xampp\htdocs\compo\src\JKetelaar\fut\api\user\Login.php:381 Stack trace: #0 C:\xampp\htdocs\compo\src\JKetelaar\fut\api\user\Login.php(98): JKetelaar\fut\api\user\Login->postTwoFactorForm('https://signin....') #1 C:\xampp\htdocs\compo\src\JKetelaar\fut\api\API.php(123): JKetelaar\fut\api\user\Login->login() #2 C:\xampp\htdocs\compo\examples\login.php(8): JKetelaar\fut\api\API->login() #3 {main} thrown in C:\xampp\htdocs\compo\src\JKetelaar\fut\api\user\Login.php on line 381

Please help... I need help urgent
Thanks in advance.

Session

It it possible to store the session? So I don't have to log in every time i refresh the page.

FIFA 18

Let's see if this is possible

totp_callback Function

What exactly is this SECRET. I believe this is not the secret answer of my FUT account. Should I use one of the backup codes?

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

return $totp->now();

}

Login

I got an error with the example login php. The error is on line 188 of API.php. What does the line mean?

public function login($path = DATA_DIR . '/cookies.txt') {

I'am also not understanding this line of the bootstrap.php

define('DATA_DIR', (($dir = drush_server_home()) === null ? __DIR__ : $dir) . '/.fut-bot/data/');

Please help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.