JKetelaar / PHP-FUT-API

The perfect PHP FUT 17 API
GNU General Public License v3.0
17 stars 5 forks source link

how to buy a player #51

Open vinch1n opened 7 years ago

vinch1n commented 7 years ago

how to buy a player

vinch1n commented 7 years ago

https://utas.external.s2.fut.ea.com/ut/game/fifa17/trade/190797669347/bid

Accept:application/json Accept-Encoding:gzip, deflate, br Accept-Language:en,zh-CN;q=0.8,zh;q=0.6 Cache-Control:no-cache Connection:keep-alive Content-Length:11 Content-Type:application/json Cookie:utag_main=v_id:015bf142e0e7000ce74c83375cbb0506d018c06500bd0$_sn:2$_ss:1$_st:1494578626160$_pn:1%3Bexp-session$ses_id:1494576826160%3Bexp-session; _nx_mpcid=745e0d75-e47d-4eb2-9d88-d54bfeb809ff Host:utas.external.s2.fut.ea.com Origin:https://www.easports.com Pragma:no-cache Referer:https://www.easports.com/iframe/fut17/bundles/futweb/web/flash/FifaUltimateTeam.swf?cl=165353 User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 X-HTTP-Method-Override:PUT X-Requested-With:ShockwaveFlash/25.0.0.171 X-UT-Embed-Error:true X-UT-PHISHING-TOKEN:8172032561996223974 X-UT-SID:927df96a-474a-4a78-a2e9-eaed7fd7d0f8

{"bid":200}

vinch1n commented 7 years ago

can i use handler.php/sendRequest function to buy player?

vinch1n commented 7 years ago

Array ( [url] => https://utas.external.s2.fut.ea.com/ut/game/fifa17/trade/190849008774/bid [content_type] => application/json;charset=utf-8 [http_code] => 200 [header_size] => 156 [request_size] => 899 [filetime] => -1 [ssl_verify_result] => 20 [redirect_count] => 0 [total_time] => 1.515 [namelookup_time] => 0 [connect_time] => 0.312 [pretransfer_time] => 1.219 [size_upload] => 11 [size_download] => 77 [speed_download] => 50 [speed_upload] => 7 [download_content_length] => 77 [upload_content_length] => 11 [starttransfer_time] => 1.515 [redirect_time] => 0 [redirect_url] => [primary_ip] => 95.138.141.11

[primary_port] => 443
[local_ip] => 169.254.92.207
[local_port] => 60898

[request_header] => POST /ut/game/fifa17/trade/190849008774/bid HTTP/1.1

Host: utas.external.s2.fut.ea.com User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko Accept-Encoding: gzip, deflate Cookie: _nx_mpcid=251e71de-9202-42e5-b4c4-6f70fae0e23e; Accept-Language: en-US,en;q=0.8 Cache-Control: no-cache Accept: application/json X-UT-Embed-Error: true X-Requested-With: ShockwaveFlash/25.0.0.171 Referer: https://www.easports.com/iframe/fut17/bundles/futweb/web/flash/FifaUltimateTeam.swf?cl=165353 Content-type: application/json X-UT-SID: 3f023b28-852f-4b3a-9312-701bdb9d5b6d X-UT-PHISHING-TOKEN: 9165947517992578238 X-HTTP-Method-Override: PUT Origin: https://www.easports.com Pragma: no-cache Content-Length: 11 )

request playload is : {"bid":200}

response: Array ( [debug] => [string] => [code] => 461 [reason] => Permission Denied )

always got code 461 error ,why would be that? how to make it right? @JKetelaar

ToniKuipers commented 7 years ago

Please provide me your PHP code.

JKetelaar commented 7 years ago

Seems like it's missing some values from cookies. Have you tried gathering the curl object from the login class?

vinch1n commented 7 years ago

my code :

        $finalUrl = sprintf(URL::API_PLACE_BID,$tradeId);

        $dataAry = array(
            'bid' => (int)$buynowPrice+100
        );

        $dataStr = json_encode($dataAry);

        $header = array(
            'Content-type' => 'application/json',
            'Accept' => 'application/json',
            'Origin'    => 'https://www.easports.com',
            'Referer'   => 'https://www.easports.com/iframe/fut17/bundles/futweb/web/flash/FifaUltimateTeam.swf?cl=165353',
            'X-Requested-With' => 'ShockwaveFlash/25.0.0.171',
            'X-UT-Embed-Error' => 'true',
            'Pragma' => 'no-cache',
            'DNT'=>null,
            'Easw-Session-Data-Nucleus-Id'=>null,
            'X-UT-Route'=>null,
            'x-flash-version'=>null,
        );

        $item = $this->handler->sendRequest($finalUrl,Method::PUT(),$dataStr,$header,false,true);

this code was excuted after $api->login() func, compare to webapp's request infomation, no utag_main cookie string contain in my request, i also curl it without logged cookies.txt.

vinch1n commented 7 years ago

the important thing is what's missing? i try to use "oczkers/fut" , got same premission denied error,is that ea changed auth way to prevent all bot actions? anyone knows? thanks very very much!

JKetelaar commented 7 years ago

Hmmm, this is somewhat related to the request to have a method to make requests to the trade market, regarding selling or buying (issue #44). So I'll try to handle this either this weekend or the next, please stay tuned!

vinch1n commented 7 years ago

okay,in the meantime,i will working on it too.

ToniKuipers commented 7 years ago

I'am not a pro like you guys, but i will try to work on it too.

JKetelaar commented 7 years ago

Thanks for all the help and support guys, really appreciate it!

JKetelaar commented 7 years ago

First base has been added in commit #de1f624.

Use it like the following:

    $handler = $api->getHandler();

    /**
     */
    $s = $handler->getSearcher()->searchFor(
        ItemType::PLAYER(),
        [],
        150,
        50
    ); // Just gathering some players

    $x = $s[0]; // Just grabbing a random object from the possible trades
    if ($x->getCurrentBid() >= 0 && $x->getCurrentBid() < 150) {
        $handler->getTrader()->placeBid($x->getId(), 150);
    }else{
        echo('Bid is above our price.');
    }

Composer:

composer require jketelaar/php-fut-api:dev-release/0.0.7

vinch1n commented 7 years ago

excellent ! check it immediately!

vinch1n commented 7 years ago

i just tried to use placebid function to buy a player , just still got 461 error message ,i wonder is that "temporary ban" rejected this request?

JKetelaar commented 7 years ago

What is the entire stacktrace? I had 461 a few times too and figured out it was because the player wasn't tradable (invalid price, already sold etc.)

vinch1n commented 7 years ago

no stacktrace,request is successful but response is 461 error。what's invalid price?

i'm setting bid price equal to buynowprice,is that correct?

i wanna buy it now,so i use buynowprice to placebid,not a higher price than startprice to bid.

JKetelaar commented 7 years ago

What if you print the current bid of the trade and also print the current status of the trade.

vinch1n commented 7 years ago

ok,i will try more ways to bid , see you around.

vinch1n commented 7 years ago

[tradeState] => active [buyNowPrice] => 700 [currentBid] => 0 [offers] => 0 [watched] => [bidState] => none [startingBid] => 650 [confidenceValue] => 100

that's a typical form of trade data,hmm,seems to be normal.

"log in Array ( [debug] => [string] => [code] => 461 [reason] => Permission Denied )"

this is bid response text,login successfully,bid error,can u try it to see got same error like mine or success response,so i can find out what's wrong with my code or my account indeed.

JKetelaar commented 7 years ago

Hmm very weird, I'll give it another shot tomorrow!