This post does not contain an AutoBuyer. It does contain PHP code that would allow you to create an AutoBuyer very easily. To stay updated with the code please use my GitHub Account.

Last week I posted code that allowed you to login to the FIFA 13 Ultimate Team Web App, today I’ve posted the code that allows you to search for players and make bids on them. The code has other functionality as well, such as retrieving player images, player JSON description files and other things.

In what ever language you prefer to code in it doesn’t take aΒ geniusΒ that putting the code together would allow you to connect and then search for specific players and bid on them based on maximum bid values you supply.

So with no further a do here is the code:

This first portion allows you to search for players and staff:

<?PHP
/**
* @llygoden
* @author - Rob McGhee
* @URL - www.robmcghee.com
* @date - 24/09/12
* @version - 1.0
**/
class Searchor {

	private $EASW_KEY;
	private $EASF_SESS;
	private $PHISHKEY;
	private $XSID;

	//initialise the class
	public function __construct($EASW_KEY, $EASF_SESS, $PHISHKEY, $XSID) {
		$this->EASW_KEY 	= $EASW_KEY;
		$this->EASF_SESS 	= $EASF_SESS;
		$this->PHISHKEY 	= $PHISHKEY;
		$this->XSID 		= $XSID;
	}

	public function playersearch($start = 0,$count = 15,$level,$formation,$position,$nationality,$league,$team,$minBid,$maxBid,$minBIN,$maxBIN){
		//URL to search for items
		$searchurl = "https://utas.fut.ea.com/ut/game/fifa13/auctionhouse?";
		//String that holds our search variables
		$searchstring = "";

		//Add to the search string based on the variables passed
		if ($level != "" && $level != "any"){
			$searchstring .= "&lev=$level";
		}

		if ($formation != "" && $formation != "any"){
			$searchstring .= "&form=$formation";
		}

		if ($position != "" && $position != "any"){
			if ($position == "defense" || $position == "midfield" || $position == "attacker"){
				$searchstring .= "&zone=$position";
			}else{
				$searchstring .= "&pos=$position";
			}
		}

		if ($nationality > 0){
			$searchstring .= "&nat=$nationality";
		}

		if ($league > 0){
			$searchstring .= "&leag=$league";
		}

		if ($team > 0){
			$searchstring .= "&team=$team";
		}

		if ($minBid > 0){
			$searchstring .= "&micr=$minBid";
		}

		if ($maxBid > 0){
			$searchstring .= "&macr=$maxBid";
		}

		if ($minBIN > 0){
			$searchstring .= "&minb=$minBid";
		}

		if ($maxBIN > 0){
			$searchstring .= "&maxb=$maxBid";
		}

		//create the final search string
		$search = $searchurl . "type=player&start=$start&num=$count" . $searchstring;
		//Set the cookie data
		$cookie_string = $this->EASW_KEY."; ".$this->EASF_SESS ."; ".$this->PHISHKEY;
		//Setup cURL HTTP request
		$ch = curl_init($search);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
			'Content-Type: application/json',
			'x-http-method-override: GET',
			$this->XSID)
		);

		//Contains the JSON file returned from EA
		$EAPSEARCH = curl_exec($ch);
		curl_close($ch);

		unset ($start,$count,$level,$formation,$position,$nationality,$league,$team,$minBid,$maxBid,$minBIN,$maxBIN, $ch, $cookie_string, $search, $searchstring);

		return $EAPSEARCH;
	}

	public function staffsearch($start = 0,$count = 15, $level, $cat, $minBid, $maxBid, $minBIN, $maxBIN){
		//URL to search for items
		$searchurl = "https://utas.fut.ea.com/ut/game/fifa13/auctionhouse?";
		//String that holds our search variables
		$searchstring = "";

		//Add to the search string based on the variables passed
		if ($level != "" && $level != "any"){
			$searchstring .= "&lev=$level";
		}

		if ($cat != "" && $cat != "any"){
			$searchstring .= "&cat=$cat";
		}

		if ($minBid > 0){
			$searchstring .= "&micr=$minBid";
		}

		if ($maxBid > 0){
			$searchstring .= "&macr=$maxBid";
		}

		if ($minBIN > 0){
			$searchstring .= "&minb=$minBid";
		}

		if ($maxBIN > 0){
			$searchstring .= "&maxb=$maxBid";
		}

		//create the final search string
		$search = $searchurl . "type=staff&blank=10&start=$start&num=$count" . $searchstring;
		//Set the cookie data
		$cookie_string = $this->EASW_KEY."; ".$this->EASF_SESS ."; ".$this->PHISHKEY;
		//Setup cURL HTTP request
		$ch = curl_init($search);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
			'Content-Type: application/json',
			'x-http-method-override: GET',
			$this->XSID)
		);

		//Contains the JSON file returned from EA
		$EASSEARCH = curl_exec($ch);
		curl_close($ch);

		unset ($start,$count,$level,$cat,$minBid,$maxBid,$minBIN,$maxBIN, $ch, $cookie_string, $search, $searchstring);

		return $EASSEARCH;
	}
}
?>

This next portion allows you to get trade information and bid on an item:

<?PHP
/**
* @llygoden
* @author - Rob McGhee
* @URL - www.robmcghee.com
* @date - 24/09/12
* @version - 1.0
**/
class Tradeor {

	private $EASW_KEY;
	private $EASF_SESS;
	private $PHISHKEY;
	private $XSID;

	//initialise the class
	public function __construct($EASW_KEY, $EASF_SESS, $PHISHKEY, $XSID) {
		$this->EASW_KEY 	= $EASW_KEY;
		$this->EASF_SESS 	= $EASF_SESS;
		$this->PHISHKEY 	= $PHISHKEY;
		$this->XSID 		= $XSID;
	}

	//$trade is the tradeID for the item you want
	//$value is the value in FIFA coins that you want to BID
	public function bid($trade, $value){
		//URL to bid on trade items
		$bidurl = "https://utas.fut.ea.com/ut/game/fifa13/trade/". $trade ."/bid";

		//JSON data to send as a POST item
		$data = array("bid" => $value);
		$data_string = json_encode($data);
		//Set the cookie data
		$cookie_string = $this->EASW_KEY."; ".$this->EASF_SESS ."; ".$this->PHISHKEY;
		//Setup cURL HTTP request
		$ch = curl_init($bidurl);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
			'Content-Type: application/json',
			'x-http-method-override: PUT',
			$this->XSID)
		);

		//Contains the JSON file returned from EA
		$EABID = curl_exec($ch);
		curl_close($ch);

		unset ($ch, $cookie_string, $data_string, $data, $trade, $bidurl, $value);

		return $EABID;
	}

	public function trade($trade){
		//URL to view trade details
		$tradeurl = "https://utas.fut.ea.com/ut/game/fifa13/trade?tradeIds=". $trade;

		//Set the cookie data
		$cookie_string = $this->EASW_KEY."; ".$this->EASF_SESS ."; ".$this->PHISHKEY;
		//Setup cURL HTTP request
		$ch = curl_init($tradeurl);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
			'Content-Type: application/json',
			'x-http-method-override: GET',
			$this->XSID)
		);

		//Contains the JSON file returned from EA
		$EATRADE = curl_exec($ch);
		curl_close($ch);

		unset($ch, $cookie_string $trade, $tradeurl);

		return $EATRADE;
	}
}
?>

And finally is a general functions class that allows you to retrieve trivial bits of information about a player.

<?PHP
/**
* @llygoden
* @author - Rob McGhee
* @URL - www.robmcghee.com
* @date - 23/09/12
* @version - 1.0
**/

//returns the base ID of a player from the resource ID provided
public function baseID($resourceid){
	$rid = $resourceid;
	$version = 0;

	WHILE ($rid > 16777216){
		$version++;
		if ($version == 1){
			//the constant applied to all items
			$rid -= 1342177280;
		}elseif ($version == 2){
			//the value added to the first updated version
			$rid -= 50331648;
		}else{
			//the value added on all subsequent versions
			$rid -= 16777216;
		}
	}

	$returnable = array('baseID'=>$rid,'version'=>$version);
	return $returnable;
}

//returns the JSON file containing the players information
public function playerinfo($baseID){
	$playerurl = "http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/web/". $baseID .".json";
	$EAPLAYER = file_get_contents($playerurl, false);

	return $EAPLAYER;
}

//returns the URL of the players image
public function playerimage($baseID){
	$EAPIMAGE = "http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/images/players/web/". $baseID .".png";

	return $EAPIMAGE;
}

//returns the JSON file containing the managers information
public function managerinfo($assetID){
	$managerurl = "http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/web/". $assetID .".json";
	$EAMANAGER = file_get_contents($managerurl, false);

	return $EAMANAGER;
}

//returns the URL of the managers image
public function managerimage($assetID){
	$EAMIMAGE = "http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/images/players/web/heads_staff_". $assetID .".png";

	return $EAMIMAGE;
}

//returns the URL of the countries flag
public function flagimage($assetID){
	$EAMIMAGE = "http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/images/cardflags/web/". $assetID .".png";

	return $EAMIMAGE;
}

//returns the URL of the countries flag
public function flagswfimage($assetID){
	$EAMIMAGE = "http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/images/cardflagssmall/web/Flag_". $assetID .".swf";

	return $EAMIMAGE;
}

//returns the URL of the clubs badge
public function clubimage($assetID){
	$EAMIMAGE = "http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/images/clubbadges/web/s". $assetID .".png";

	return $EAMIMAGE;
}

//returns the JSON file containing how many coins your account has to spend	
public function credits($EASW_KEY, $EASF_SESS, $PHISHKEY, $XSID){
	//URL to retrieve credits
	$creditsurl = "https://utas.fut.ea.com/ut/game/fifa13/user/credits";

	//Set the cookie data
	$cookie_string = $EASW_KEY."; ".$EASF_SESS ."; ".$PHISHKEY;                                                                       
	//Setup cURL HTTP request
	$ch = curl_init($creditsurl);                                                                      
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                                                                                     
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($ch, CURLOPT_COOKIE, $cookie_string); 
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
		'Content-Type: application/json',                                                                                
		'x-http-method-override: GET',
		$XSID)                                                                       
	);

	//Contains the JSON file returned from EA
	$EACREDITS = curl_exec($ch);
	curl_close($ch);

	unset ($ch, $cookie_string, $trade, $tradeurl, $value);

	return $EACREDITS;
}

//Return the type of card we have
public function cardtype($rating, $rare){

	$type = "Gold";
	//Set the Colour based on the player rating
	if ($rating <= 64){
		$type = "Bronze";
	}elseif ($rating <= 74){
		$type = "Silver";
	}

	//Set the Catagory based on the player rareity
	switch($rare):
		case 1:
			$type .= " Shiny";
			break;
		case 3:
			$type .= " InForm";
			break;
		case 5:
			$type .= " TOTY";
			break;
		case 6:
			$type .= " TOTY";
			break;
		case 8:
			$type .= " MOTM";
	endswitch;

	//Return the Card Type
	return $type;
}
?>