daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Oct 22nd, 2011 1,375 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. import java.util.*;
  3. import java.net.*;
  4.  
  5. /**
  6.  * @author pmzipko
  7.  * @date 7/26/2011
  8.  * @version 2.2
  9.  */
  10. public class FUTClient {
  11.     private String user;
  12.     private String password;
  13.     private String securityQ;
  14.     public int lastTradeId;
  15.     //Was having trouble with java's built in cookie handler, so I wrote my own. EASW_KEY and PhishingKey are the two critical cookies needed
  16.     //to authenticate with the EA servers. They are retrieved durring the connect() and AnswerSecurityQ() methods.
  17.     private static String EASW_KEY;
  18.     private static String PhishingKey;
  19.  
  20.  
  21.     public FUTClient(String iniFile){
  22.     //class constructor, takes a string file name. This file is to be a text ini file with the following properties
  23.     //#user = UserName
  24.     //#password = Password
  25.     //#SecurityQuestion = HashedSecurityQ
  26.     //
  27.     //Note, the security question is no the plain text answer to your question, it's the hash that the web app creates and sends to the server.
  28.     //this was easier than bothering to hash it myself here. To get the hash use any tool to intercept http traffic and monitor the data sent
  29.     //when you answer the question. Copy and paste the hash sent to your ini file.
  30.             try{
  31.                 Properties p = new Properties();
  32.                 p.load(new FileInputStream(iniFile));
  33.                 user = p.getProperty("user");
  34.                 password = p.getProperty("password");
  35.                 securityQ = p.getProperty("SecurityQuestion");
  36.             }catch(IOException e){System.out.println("ini file not found: "+e.toString());}
  37.         }
  38.  
  39.     public void connect(){
  40.         //logs into the EA web app with the username and password provided in the ini file. This required to establish an EASW_KEY.
  41.              HttpURLConnection   urlConn;
  42.              URL url;
  43.              DataOutputStream  printout;
  44.              DataInputStream  input;
  45.              // URL of CGI-Bin script.
  46.              url = null;
  47.              try{
  48.  
  49.                 url = new URL ("https://www.ea.com/uk/football/services/authenticate/login");}
  50.                 catch(java.net.MalformedURLException e){}
  51.              // URL connection channel.
  52.              try{
  53.                 urlConn = (HttpURLConnection)url.openConnection();
  54.                 // Let the run-time system (RTS) know that we want input.
  55.                 urlConn.setDoInput (true);
  56.                 // Let the RTS know that we want to do output.
  57.                 urlConn.setDoOutput (true);
  58.                 // No caching, we want the real thing.
  59.                 urlConn.setUseCaches (false);
  60.                 urlConn.setAllowUserInteraction(true);
  61.                 // Specify the content type.
  62.                 urlConn.setRequestProperty
  63.                       ("Content-Type", "application/x-www-form-urlencoded");
  64.                 // Send POST output.
  65.                 printout = new DataOutputStream (urlConn.getOutputStream ());
  66.                 String content ="email="+user+"&password="+password+"&=Sign+In";
  67.                 printout.writeBytes (content);
  68.                 // Let the run-time system (RTS) know that we want input.
  69.                printout.flush ();
  70.                 printout.close ();
  71.                 // Get response data.
  72.                input = new DataInputStream (urlConn.getInputStream ());
  73.  
  74.                 String str;
  75.                 while (null != ((str = input.readLine())))
  76.                 {
  77.                 }
  78.  
  79.                // System.out.println("reconnected");
  80.                 //retrieves the EASW_KEY cookie from the URLConnection
  81.                 Map<String,List<String>> cm = urlConn.getHeaderFields();
  82.                 List<String> cl = cm.get("Set-Cookie");
  83.                 input.close ();
  84.                 int cmLength = cl.size();
  85.                 if (cmLength>0){
  86.                     for (int i=0; i<cmLength;i++){
  87.                         int index;
  88.                         String cookieS = cl.get(i);
  89.                         if((index=cookieS.indexOf("EASW_KEY=")) != -1){
  90.                             int index2 = cookieS.indexOf(";", index);
  91.                             EASW_KEY = cookieS.substring(index, index2);
  92.                         }
  93.                     }
  94.                 }
  95.                 AnswerSecurityQ();
  96.  
  97.              }
  98.                 catch(IOException e){System.out.println("connect: connection failed "+ e.toString());}
  99.          }
  100. public void AnswerSecurityQ(){
  101.     //Answers the security question with the hash provided in the ini file. This is required to retrieve the FUTWebPhishing cookie.
  102.   URL url;
  103.              URLConnection   urlConn;
  104.              DataOutputStream  printout;
  105.              DataInputStream  input;
  106.              // URL of CGI-Bin script.
  107.              url = null;
  108.              try{
  109.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_US/s/p/ut/game/ut11/phishing/validate");}
  110.                 catch(java.net.MalformedURLException e){}
  111.              // URL connection channel.
  112.              try{
  113.                 urlConn = url.openConnection();
  114.                 // Let the run-time system (RTS) know that we want input.
  115.                 urlConn.setDoInput (true);
  116.                 // Let the RTS know that we want to do output.
  117.                 urlConn.setDoOutput (true);
  118.                 // No caching, we want the real thing.
  119.                 urlConn.setUseCaches (false);
  120.                 // Specify the content type.
  121.                 urlConn.setRequestProperty
  122.                       ("Content-Type", "application/x-www-form-urlencoded");
  123.                 urlConn.addRequestProperty("Cookie", EASW_KEY);
  124.  
  125.                 // Send POST output.
  126.                 printout = new DataOutputStream (urlConn.getOutputStream ());
  127.                 String content ="answer="+securityQ;
  128.                 printout.writeBytes (content);
  129.                 // Let the run-time system (RTS) know that we want input.
  130.  
  131.                 printout.flush ();
  132.                 printout.close ();
  133.                 // Get response data.
  134.                 input = new DataInputStream (urlConn.getInputStream ());
  135.                 String str;
  136.                 while (null != ((str = input.readLine())))
  137.                 {
  138.                 }
  139.                 input.close ();
  140.  
  141.                 //retrieves the FUTWebPhishing cookie from the URLConnection
  142.                 Map<String,List<String>> cm = urlConn.getHeaderFields();
  143.                 List<String> cl = cm.get("Set-Cookie");
  144.                 input.close ();
  145.                 int cmLength = cl.size();
  146.                 if (cmLength>0){
  147.                     for (int i=0; i<cmLength;i++){
  148.                         int index;
  149.                         String cookieS = cl.get(i);
  150.                         if((index=cookieS.indexOf("FUTWebPhishing")) != -1){
  151.                             int index2 = cookieS.indexOf(";", index);
  152.                             PhishingKey = cookieS.substring(index, index2);
  153.                         }
  154.                     }
  155.                 }
  156.  
  157.              }
  158.                 catch(IOException e){System.out.println("connect: connection failed "+ e.toString());}
  159.          }
  160.     public  String search(int start,int count,String level,String formation,String position,int nationality,int league,int team, int minBid,int maxBid,int minBIN,int maxBIN){
  161.             //This method will search the players trading market based on parameters entered. Any of these parameters may be left blank and default vaules will be used.
  162.             //Nationality, league and team are enumerations. Enter the integer for the appropriate value you want. Some samples are below, but to get more values use
  163.             //any tool to monitor http traffic while performing searches and you'll see what values the web app uses for various selections.
  164.            
  165.             //This search returns an xml string that can be parsed to analyse the results. Note, only 16 or so results are returned max each search, to search larger data sets
  166.             //increment start. Count is the number of results to retrieve. For example, you can make continuous searches with start=0, count=10, then increment start by 10 each
  167.             //time until no further results are returned.
  168.        
  169.             //Valid enumerations
  170.             //level = "gold", "bronze", "silver"
  171.             //formation = "f433", "f352", "f41212", ect...
  172.             //position = "defense", "midfield", "attacker", other positions are same as app
  173.             //nationality = 51 - Argentina, 54 - Brazil, 14 - England, 18 - France, 21 - Germany, 27 - Italy,
  174.             //38 - Portugal, 40 - Russia, 45 - Spain, 60 - Uraguay
  175.             //league = 13 - EPL, 19 - Bundesliga, 31 - Serie A, 39 - MLS, 53 - BBVA
  176.             //team =
  177.              URL url;
  178.              URLConnection   urlConn;
  179.              DataOutputStream  printout;
  180.              DataInputStream  input;
  181.              StringBuilder returnStr = new StringBuilder();
  182.                     //setup level string
  183.              Date now = new Date();
  184.              Long longTime = now.getTime();
  185.  
  186.              StringBuilder levelString = new StringBuilder();
  187.              if (level.equals("") || level.equals("any"))
  188.                 levelString.append("");
  189.              else
  190.                 levelString.append("&lev="+level);
  191.  
  192.           //setup position string
  193.  
  194.              StringBuilder positionString = new StringBuilder();
  195.              if (position.equals("") || position.equals("any")){
  196.                 positionString.append("");
  197.              }
  198.              else {
  199.                 if (position.equals("defense") || position.equals("midfield") || position.equals("attacker"))
  200.                    positionString.append("&zone="+position);
  201.                 else
  202.                    positionString.append("&pos="+position);
  203.              }
  204.  
  205.           //setup formation string
  206.  
  207.              StringBuilder formationString = new StringBuilder();
  208.              if (formation.equals("") || formation.equals("any")){
  209.                 formationString.append("");
  210.              }
  211.              else {
  212.                 formationString.append("&form="+formation);
  213.              }
  214.  
  215.           //setup nationality string
  216.  
  217.              StringBuilder nationalityString = new StringBuilder();
  218.              if(nationality > 0)
  219.                 nationalityString.append("&nat="+nationality);
  220.              else
  221.                 nationalityString.append("");
  222.  
  223.           //setup league string
  224.  
  225.              StringBuilder leagueString = new StringBuilder();
  226.              if(league > 0)
  227.                 leagueString.append("&leag="+league);
  228.              else
  229.                 leagueString.append("");
  230.  
  231.           //setup team string
  232.  
  233.              StringBuilder teamString = new StringBuilder();
  234.              if(team > 0)
  235.                 teamString.append("&team="+team);
  236.              else
  237.                 teamString.append("");
  238.  
  239.           //setup min bid string
  240.  
  241.              StringBuilder minBidString = new StringBuilder();
  242.              if(minBid > 0)
  243.                 minBidString.append("&minr="+minBid);
  244.              else
  245.                 minBidString.append("");
  246.  
  247.           //setup max bid string
  248.  
  249.              StringBuilder maxBidString = new StringBuilder();
  250.              if(maxBid > 0)
  251.                 maxBidString.append("&maxr="+maxBid);
  252.              else
  253.                 maxBidString.append("");
  254.  
  255.           //setup min BIN string
  256.  
  257.              StringBuilder minBINString = new StringBuilder();
  258.              if(minBIN > 0)
  259.                 minBINString.append("&minb="+minBIN);
  260.              else
  261.                 minBINString.append("");
  262.  
  263.           //setup max BIN string
  264.  
  265.              StringBuilder maxBINString = new StringBuilder();
  266.              if(maxBIN > 0)
  267.                 maxBINString.append("&maxb="+maxBIN);
  268.              else
  269.                 maxBINString.append("");
  270.  
  271.           // URL of CGI-Bin script.
  272.              url = null;
  273.              try{
  274.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/auctionhouse?type=player&start="+start+"&num="+count+levelString+formationString+positionString+nationalityString+leagueString+teamString+minBidString+maxBidString+minBINString+maxBINString+"&timestamp="+longTime);
  275.              //System.out.println(url);
  276.              }
  277.                 catch(java.net.MalformedURLException e){ connect();System.out.println("search: Malformed URL"+e.toString());}
  278.           // URL connection channel.
  279.              try{
  280.                 urlConn = url.openConnection();
  281.  
  282.              // Let the run-time system (RTS) know that we want input.
  283.                 urlConn.setDoInput (true);
  284.              // Let the RTS know that we want to do output.
  285.              //urlConn.setDoOutput (true);
  286.              // No caching, we want the real thing.
  287.                 urlConn.setUseCaches (false);
  288.              // Specify the content type.
  289.              //urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  290.              // Send POST output.
  291.              //printout = new DataOutputStream (urlConn.getOutputStream ());
  292.               //printout.writeBytes (content);
  293.              //printout.flush ();
  294.              //printout.close ();
  295.              // Get response data.
  296.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  297.                 input = new DataInputStream (urlConn.getInputStream ());
  298.              //input = new DataInputStream (url.openStream());
  299.  
  300.                 String str;
  301.                 while (null != (str = input.readLine()))
  302.                 {
  303.                    returnStr.append(str);
  304.                 }
  305.                 input.close ();
  306.              }
  307.                 catch(IOException e)
  308.                 {
  309.         }
  310.  
  311.              return returnStr.toString();
  312.           }
  313.     public  String searchTraining(String level, String type, int start, int count, int MaxB){
  314.             //searches through traning cards, much simplier than the player search. Takes a string for bronze, silver, gold and a type for the
  315.             //type of card. Increment start with a fixed count to step through the pages.
  316.              URL url;
  317.              URLConnection   urlConn;
  318.              DataOutputStream  printout;
  319.              DataInputStream  input;
  320.              StringBuilder returnStr = new StringBuilder();
  321.  
  322.           // URL of CGI-Bin script.
  323.              url = null;
  324.              try{
  325.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/auctionhouse?type=training&cat="+type+"&blank=10&start="+start+"&num="+count+"&maxb="+MaxB+"&timestamp=0");
  326.              //System.out.println(url);
  327.              }
  328.              catch(java.net.MalformedURLException e){ connect();System.out.println("search: Malformed URL"+e.toString());}
  329.           // URL connection channel.
  330.              try{
  331.                 urlConn = url.openConnection();
  332.  
  333.              // Let the run-time system (RTS) know that we want input.
  334.                 urlConn.setDoInput (true);
  335.              // Let the RTS know that we want to do output.
  336.              //urlConn.setDoOutput (true);
  337.              // No caching, we want the real thing.
  338.                 urlConn.setUseCaches (false);
  339.              // Specify the content type.
  340.              //urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  341.              // Send POST output.
  342.              //printout = new DataOutputStream (urlConn.getOutputStream ());
  343.             //printout.writeBytes (content);
  344.              //printout.flush ();
  345.              //printout.close ();
  346.              // Get response data.
  347.  
  348.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  349.                 input = new DataInputStream (urlConn.getInputStream ());
  350.              //input = new DataInputStream (url.openStream());
  351.  
  352.                 String str;
  353.                 while (null != (str = input.readLine()))
  354.                 {
  355.                    returnStr.append(str);
  356.                 }
  357.                 input.close ();
  358.              }
  359.                 catch(IOException e)
  360.                 {
  361.                
  362.                    try
  363.                    {
  364.                       Thread.sleep(2000);
  365.                    }
  366.                       catch(Exception e2)
  367.                       {
  368.                       }
  369.                   // System.out.println("search: retrieve search "+e.toString());
  370.                 }
  371.  
  372.              return returnStr.toString();
  373.           }
  374.  
  375.     public  boolean buy(int tradeID, int amount, String playerName){
  376.         //places a bid of the set amount on a particular trade. The string playerName isn't used as part of the transaction, but is passed
  377.         //so I can message the name of the card bought.
  378.              URL url;
  379.              URLConnection   urlConn;
  380.              DataOutputStream  printout;
  381.              DataInputStream  input;
  382.  
  383.              StringBuilder returnStr = new StringBuilder();
  384.  
  385.           // URL of CGI-Bin script.
  386.              url = null;
  387.  
  388.              try{
  389.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/put/game/ut11/trade/"+tradeID+"/bid");}
  390.                 catch(java.net.MalformedURLException e){connect();System.out.println("Buy: malformed URL "+ e.toString());}
  391.           // URL connection channel.
  392.              try{
  393.                 urlConn = url.openConnection();
  394.              // Let the run-time system (RTS) know that we want input.
  395.                 urlConn.setDoInput (true);
  396.              // Let the RTS know that we want to do output.
  397.                 urlConn.setDoOutput (true);
  398.              // No caching, we want the real thing.
  399.                 urlConn.setUseCaches (false);
  400.              // Specify the content type.
  401.                 urlConn.setRequestProperty
  402.                    ("Content-type", "text/xml");
  403.  
  404.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  405.              // Send POST output.
  406.                 printout = new DataOutputStream (urlConn.getOutputStream ());
  407.                 String content ="<auctionInfo tradeId='"+tradeID+"'><bid>"+amount+"</bid></auctionInfo>";
  408.                 printout.writeBytes (content);
  409.              // Let the run-time system (RTS) know that we want input.
  410.  
  411.                 printout.flush ();
  412.                 printout.close ();
  413.              // Get response data.
  414.                 input = new DataInputStream (urlConn.getInputStream ());
  415.                 String str;
  416.                 while (null != (str = input.readLine()))
  417.                 {
  418.                    returnStr.append(str);
  419.                 }
  420.                 input.close ();
  421.              }
  422.                 catch(IOException e){connect();System.out.println("Buy: exception buying "+e.toString());}
  423.              //System.out.println(returnStr.toString());
  424.              
  425.              //somewhat dead code to keep track of if an attempt to buy a player failed and message it. Can be safely removed.
  426.              if(returnStr.toString().indexOf("<error>")==-1){
  427.                 lastTradeId = tradeID;
  428.                  return true;
  429.             }else{
  430.                 //if(lastTradeId != tradeID)
  431.                    // System.out.println("Trade Failed: "+playerName+" "+tradeID + " " + amount);
  432.                 return false;
  433.             }
  434.           }
  435.     public  boolean buyPack(int packId, String payForIt){
  436.         //dead code, this is not the real buy pack method. It's a method I wrote to try messing with the free gift packs, but didn't work.
  437.              URL url;
  438.              URLConnection   urlConn;
  439.              DataOutputStream  printout;
  440.              DataInputStream  input;
  441.  
  442.              StringBuilder returnStr = new StringBuilder();
  443.  
  444.           // URL of CGI-Bin script.
  445.              url = null;
  446.  
  447.              try{
  448.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/purchased/items");}
  449.                 catch(java.net.MalformedURLException e){connect();System.out.println("Buy: malformed URL "+ e.toString());}
  450.           // URL connection channel.
  451.              try{
  452.                 urlConn = url.openConnection();
  453.              // Let the run-time system (RTS) know that we want input.
  454.                 urlConn.setDoInput (true);
  455.              // Let the RTS know that we want to do output.
  456.                 urlConn.setDoOutput (true);
  457.              // No caching, we want the real thing.
  458.                 urlConn.setUseCaches (false);
  459.              // Specify the content type.
  460.  
  461.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  462.                 urlConn.setRequestProperty
  463.                    ("Content-type", "text/xml");
  464.              // Send POST output.
  465.                 printout = new DataOutputStream (urlConn.getOutputStream ());
  466.                 String content ="<packTypeId useCredits='"+payForIt+"'>"+packId+"</packTypeId>";
  467.                 printout.writeBytes (content);
  468.              // Let the run-time system (RTS) know that we want input.
  469.  
  470.                 printout.flush ();
  471.                 printout.close ();
  472.              // Get response data.
  473.                 input = new DataInputStream (urlConn.getInputStream ());
  474.                 String str;
  475.                 while (null != (str = input.readLine()))
  476.                 {
  477.                    returnStr.append(str);
  478.                 }
  479.                 input.close ();
  480.              }
  481.              catch(IOException e){connect();System.out.println("Buy: exception buying "+e.toString());}
  482.              System.out.println(returnStr.toString());
  483.              if(returnStr.toString().indexOf("<error>")==-1){
  484.  
  485.                  return true;
  486.             }else{
  487.                  return false;
  488.             }
  489.           }
  490.     public  boolean buyTokens(){
  491.         //buys bid tokens. May no longer be functional, changes to the bid tokens on the market probably broke this but I haven't tested it since.
  492.              URL url;
  493.              URLConnection   urlConn;
  494.              DataOutputStream  printout;
  495.              DataInputStream  input;
  496.  
  497.              StringBuilder returnStr = new StringBuilder();
  498.  
  499.           // URL of CGI-Bin script.
  500.              url = null;
  501.  
  502.              try{
  503.                 url = new URL ("http://pals.www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/user/bidTokens");}
  504.                 catch(java.net.MalformedURLException e){connect();System.out.println("Buy: malformed URL "+ e.toString());}
  505.           // URL connection channel.
  506.              try{
  507.                 urlConn = url.openConnection();
  508.              // Let the run-time system (RTS) know that we want input.
  509.                 urlConn.setDoInput (true);
  510.              // Let the RTS know that we want to do output.
  511.                 urlConn.setDoOutput (true);
  512.              // No caching, we want the real thing.
  513.                 urlConn.setUseCaches (false);
  514.              // Specify the content type.
  515.                 urlConn.setRequestProperty
  516.                    ("Content-type", "text/xml");
  517.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  518.  
  519.              // Send POST output.
  520.                 printout = new DataOutputStream (urlConn.getOutputStream ());
  521.                
  522.                 //With the change to the market to have 3 different bid token packages, look up the purchase id to find the right one to buy.
  523.                 String content ="<purchaseGroup id='token'><purchase id='70'/></purchaseGroup>";
  524.                 printout.writeBytes (content);
  525.  
  526.                 // Let the run-time system (RTS) know that we want input.
  527.  
  528.                 printout.flush ();
  529.                 printout.close ();
  530.              // Get response data.
  531.                 input = new DataInputStream (urlConn.getInputStream ());
  532.                 String str;
  533.                 while (null != (str = input.readLine()))
  534.                 {
  535.                    returnStr.append(str);
  536.                 }
  537.                 input.close ();
  538.              }
  539.              catch(IOException e){connect();System.out.println("Buy: exception buying "+e.toString());}
  540.              System.out.println(returnStr.toString());
  541.              if(returnStr.toString().indexOf("<error>")==-1){
  542.  
  543.                  return true;
  544.             }else{
  545.                  return false;
  546.             }
  547.           //return "";
  548.           }
  549.     public void postTrade(String itemID, int startBid, int buyNow, int duration){
  550.         // post a player up for sale. Item ID of the card, start price, BIN price, length of time in seconds.
  551.         //minimum buy price is 50c and minimum duration is 3600 seconds.
  552.        
  553.         URL url;
  554.         URLConnection   urlConn;
  555.         DataOutputStream  printout;
  556.         DataInputStream  input;
  557.  
  558.         StringBuilder returnStr = new StringBuilder();
  559.  
  560.         // URL of CGI-Bin script.
  561.         url = null;
  562.  
  563.         try{
  564.             url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/auctionhouse");}
  565.         catch(java.net.MalformedURLException e){connect();System.out.println("Buy: malformed URL "+ e.toString());}
  566.         // URL connection channel.
  567.        try{
  568.         urlConn = url.openConnection();
  569.          // Let the run-time system (RTS) know that we want input.
  570.         urlConn.setDoInput (true);
  571.         // Let the RTS know that we want to do output.
  572.         urlConn.setDoOutput (true);
  573.         // No caching, we want the real thing.
  574.         urlConn.setUseCaches (false);
  575.         // Specify the content type.
  576.         urlConn.setRequestProperty
  577.         ("Content-type", "text/xml");
  578.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  579.  
  580.         // Send POST output.
  581.         printout = new DataOutputStream (urlConn.getOutputStream ());
  582.         String content ="<auctionInfo><itemData id='"+itemID+"'/><startingBid>"+startBid+"</startingBid><buyNowPrice>"+buyNow+"</buyNowPrice><duration>"+duration+"</duration></auctionInfo>";
  583.         //System.out.println(content);
  584.         printout.writeBytes (content);
  585.         // Let the run-time system (RTS) know that we want input.
  586.  
  587.         printout.flush ();
  588.         printout.close ();
  589.         // Get response data.
  590.         input = new DataInputStream (urlConn.getInputStream ());
  591.         String str;
  592.         while (null != (str = input.readLine()))
  593.         {
  594.             returnStr.append(str);
  595.          }
  596.          input.close ();
  597.         }catch(IOException e){connect();System.out.println("Post Auction: exception buying "+e.toString());}
  598.         //System.out.println("postTrade: " +returnStr.toString());
  599.  
  600.       }
  601.      public  boolean tradeOffer(int tradeID, int amount, Collection<String> playerIDs){
  602.          //make a trade offer. TradeID is the card you want to offer on. Amount is the amount of coins to offer. playerIDs is a
  603.          //collection of ItemIDs of the cards you want to offer.
  604.          //NOTE: there used to be an amusing bug where if you listed the same ID multiple times in the collection it would show the persons
  605.          //seeing the trade multiple versions of that card. It's bugged though so they can't accept the trade. Haven't tested in months
  606.          //though, don't know if patched.
  607.          
  608.              URL url;
  609.              URLConnection   urlConn;
  610.              DataOutputStream  printout;
  611.              DataInputStream  input;
  612.  
  613.              StringBuilder returnStr = new StringBuilder();
  614.              StringBuilder content = new StringBuilder();
  615.           // URL of CGI-Bin script.
  616.              url = null;
  617.  
  618.              try{
  619.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/trade/"+tradeID+"/offer");}
  620.                 catch(java.net.MalformedURLException e){connect();System.out.println("Buy: malformed URL "+ e.toString());}
  621.           // URL connection channel.
  622.              try{
  623.                 urlConn = url.openConnection();
  624.              // Let the run-time system (RTS) know that we want input.
  625.                 urlConn.setDoInput (true);
  626.              // Let the RTS know that we want to do output.
  627.                 urlConn.setDoOutput (true);
  628.              // No caching, we want the real thing.
  629.                 urlConn.setUseCaches (false);
  630.              // Specify the content type.
  631.                 urlConn.setRequestProperty
  632.                    ("Content-type", "text/xml");
  633.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  634.  
  635.              // Send POST output.
  636.                 printout = new DataOutputStream (urlConn.getOutputStream ());
  637.                 content.append("<auctionInfo><bid>"+amount+"</bid>");
  638.                 for (Iterator it=playerIDs.iterator(); it.hasNext( ); ) {
  639.                     Object anObject = it.next( );
  640.                     content.append("<itemData id='"+anObject.toString()+"'/>");
  641.                 }
  642.                 content.append("</auctionInfo>");
  643.                 printout.writeBytes (content.toString());
  644.              // Let the run-time system (RTS) know that we want input.
  645.  
  646.                 printout.flush ();
  647.                 printout.close ();
  648.              // Get response data.
  649.                 input = new DataInputStream (urlConn.getInputStream ());
  650.                 String str;
  651.                 while (null != (str = input.readLine()))
  652.                 {
  653.                    returnStr.append(str);
  654.                 }
  655.                 input.close ();
  656.              }
  657.                 catch(IOException e){connect();System.out.println("Trade Offer: exception buying "+e.toString());}
  658.              //System.out.println(returnStr.toString());
  659.              if(returnStr.toString().indexOf("<error>")==-1){
  660.  
  661.                  return true;
  662.             }else{
  663.                 return false;
  664.             }
  665.           //return "";
  666.           }
  667.    public void movePlayer(String itemID, String pile){
  668.        //move a card in your account. trade sends them to your trade pile, club sends them back to the club.
  669.        
  670.         URL url;
  671.         URLConnection   urlConn;
  672.         DataOutputStream  printout;
  673.         DataInputStream  input;
  674.         //valid piles - "trade", "club"
  675.         StringBuilder returnStr = new StringBuilder();
  676.  
  677.         // URL of CGI-Bin script.
  678.         url = null;
  679.  
  680.         try{
  681.             url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/put/game/ut11/item");}
  682.         catch(java.net.MalformedURLException e){connect();System.out.println("Buy: malformed URL "+ e.toString());}
  683.         // URL connection channel.
  684.        try{
  685.         urlConn = url.openConnection();
  686.          // Let the run-time system (RTS) know that we want input.
  687.         urlConn.setDoInput (true);
  688.         // Let the RTS know that we want to do output.
  689.         urlConn.setDoOutput (true);
  690.         // No caching, we want the real thing.
  691.         urlConn.setUseCaches (false);
  692.         // Specify the content type.
  693.         urlConn.setRequestProperty
  694.         ("Content-type", "text/xml");
  695.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  696.  
  697.         // Send POST output.
  698.         printout = new DataOutputStream (urlConn.getOutputStream ());
  699.         String content ="<items><itemData id='"+itemID+"'><pile>"+pile+"</pile></itemData></items>";
  700.         //System.out.println(content);
  701.         printout.writeBytes (content);
  702.         // Let the run-time system (RTS) know that we want input.
  703.  
  704.         printout.flush ();
  705.         printout.close ();
  706.         // Get response data.
  707.         input = new DataInputStream (urlConn.getInputStream ());
  708.         String str;
  709.         while (null != (str = input.readLine()))
  710.         {
  711.             returnStr.append(str);
  712.          }
  713.          input.close ();
  714.         }catch(IOException e){connect();System.out.println("Post Auction: exception buying "+e.toString());}
  715.         //System.out.println("move: "+returnStr.toString());
  716.  
  717.       }
  718.     public String GetNewCards(){
  719.         //When you open a pack, this method will retrieve the list of cards you recieved in that pack.
  720.        
  721.         URL url;
  722.         URLConnection   urlConn;
  723.         DataOutputStream  printout;
  724.         DataInputStream  input;
  725.         StringBuilder returnStr = new StringBuilder();
  726.  
  727.         // URL of CGI-Bin script.
  728.          url = null;
  729.              try{
  730.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/purchased/items?timestamp=0");
  731.              //System.out.println(url);
  732.              }
  733.              catch(java.net.MalformedURLException e){ connect();System.out.println("search: Malformed URL"+e.toString());}
  734.           // URL connection channel.
  735.              try{
  736.                 urlConn = url.openConnection();
  737.  
  738.              // Let the run-time system (RTS) know that we want input.
  739.                 urlConn.setDoInput (true);
  740.              // Let the RTS know that we want to do output.
  741.              //urlConn.setDoOutput (true);
  742.              // No caching, we want the real thing.
  743.                 urlConn.setUseCaches (false);
  744.              // Specify the content type.
  745.              //urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  746.              // Send POST output.
  747.              //printout = new DataOutputStream (urlConn.getOutputStream ());
  748.              //String content ="start=0&lev=gold&type=player&num=16&timestamp=1291773340890";
  749.              //printout.writeBytes (content);
  750.              //printout.flush ();
  751.              //printout.close ();
  752.              // Get response data.
  753.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  754.  
  755.                 input = new DataInputStream (urlConn.getInputStream ());
  756.              //input = new DataInputStream (url.openStream());
  757.  
  758.                 String str;
  759.                 while (null != (str = input.readLine()))
  760.                 {
  761.                    returnStr.append(str);
  762.                 }
  763.                 input.close ();
  764.         }catch(IOException e){connect();System.out.println("Post Auction: exception buying "+e.toString());}
  765.         return returnStr.toString();
  766.  
  767.       }
  768.    
  769. public String getTrade(int TradeID){
  770.     //This method will get the trade data for any card. This includes cards you don't own, so if you want to see what trades
  771.     //someone has on their card call this method with the auctionID of the card you want to examine.
  772.    
  773.              URL url;
  774.              URLConnection   urlConn;
  775.              DataOutputStream  printout;
  776.              DataInputStream  input;
  777.              StringBuilder returnStr = new StringBuilder();
  778.  
  779.           // URL of CGI-Bin script.
  780.              url = null;
  781.              try{
  782.                 url = new URL ("http://www.ea.com/p/fut/a/card/l/en_GB/s/p/ut/game/ut11/trade/"+TradeID+"?timestamp=0");
  783.              //System.out.println(url);
  784.              }
  785.              catch(java.net.MalformedURLException e){ connect();System.out.println("search: Malformed URL"+e.toString());}
  786.           // URL connection channel.
  787.              try{
  788.                 urlConn = url.openConnection();
  789.  
  790.              // Let the run-time system (RTS) know that we want input.
  791.                 urlConn.setDoInput (true);
  792.              // Let the RTS know that we want to do output.
  793.              //urlConn.setDoOutput (true);
  794.              // No caching, we want the real thing.
  795.                 urlConn.setUseCaches (false);
  796.              // Specify the content type.
  797.              //urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  798.              // Send POST output.
  799.              //printout = new DataOutputStream (urlConn.getOutputStream ());
  800.              //String content ="start=0&lev=gold&type=player&num=16&timestamp=1291773340890";
  801.              //printout.writeBytes (content);
  802.              //printout.flush ();
  803.              //printout.close ();
  804.              // Get response data.
  805.                 urlConn.addRequestProperty("Cookie", EASW_KEY+";"+PhishingKey);
  806.  
  807.                 input = new DataInputStream (urlConn.getInputStream ());
  808.              //input = new DataInputStream (url.openStream());
  809.  
  810.                 String str;
  811.                 while (null != (str = input.readLine()))
  812.                 {
  813.                    returnStr.append(str);
  814.                 }
  815.                 input.close ();
  816.              }
  817.                 catch(IOException e)
  818.                 {
  819.                   /* Date currentDate=new Date();
  820.                    long currentTime=currentDate.getTime();
  821.                    if(Find.connecting==false && (currentTime-Find.lastReconnect)>5000)
  822.                    {
  823.                       Find.lastReconnect=currentTime;
  824.                       Find.connecting=true;
  825.                       connect();
  826.                    }*/
  827.                     System.out.println("Get Trade Exception: "+ e);
  828.                    try
  829.                    {
  830.                       Thread.sleep(2000);
  831.                    }
  832.                       catch(Exception e2)
  833.                       {
  834.                       }
  835.                   // System.out.println("search: retrieve search "+e.toString());
  836.                 }
  837.              if(returnStr.indexOf("Invalid Cookie")>0){
  838.                     connect();
  839.                     returnStr = new StringBuilder(getTrade(TradeID));
  840.              }
  841.              return returnStr.toString();
  842.           }
  843. }
  844.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top