Advertisement
Guest User

Untitled

a guest
May 10th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <?
  2. $servername = 'localhost';
  3. $username = 'relictra_user';
  4. $password = 'password';
  5. $schema = 'relictra_darksorrow';
  6. $apiKey = 'by8q5nmrysrbaky3z59hc5ykr43tsgjr';
  7. $realmName = 'darksorrow';
  8. $realmRegion = 'eu';
  9.  
  10. $conn = new mysqli($servername, $username, $password, $schema); $conn->set_charset('utf8');
  11. if ($conn->connect_error) { die('Connection failed: ' . $conn->connect_error); }
  12.  
  13. $response = file_get_contents('https://'. $realmRegion .'.api.battle.net/wow/auction/data/'. $realmName .'?locale=en_GB&apikey=' . $apiKey); $responseObject = json_decode($response, true);
  14.  
  15. $a=json_decode($response,true);
  16.  
  17. $sql = "INSERT INTO status (realm) VALUES(".$responseObject['files'][0]['lastModified'].");";
  18. //$conn->query($sql);
  19.  
  20.  
  21.  
  22. $checkdate="select realm from status where realm=(select max(realm) from status);";
  23.  
  24. $result3 = $conn->query($checkdate);
  25.  
  26.  
  27.  
  28. if ($result3->num_rows > 0) {
  29. // output data of each row
  30. while($row = $result3->fetch_assoc())
  31.  
  32. $lastentry=$row["realm"];
  33.  
  34.  
  35. if ($lastentry==$responseObject['files'][0]['lastModified'])
  36. {
  37. echo '<br>';
  38.  
  39. }
  40.  
  41. else {
  42. $conn ->query("TRUNCATE TABLE auctions");
  43. $conn ->query("TRUNCATE TABLE status");
  44.  
  45. $response = file_get_contents('https://'. $realmRegion .'.api.battle.net/wow/auction/data/'. $realmName .'?locale=en_GB&apikey=' . $apiKey); $responseObject = json_decode($response, true);
  46. $a=json_decode($response,true);
  47. $sql = "INSERT INTO status (realm) VALUES(".$responseObject['files'][0]['lastModified'].");";
  48. $conn->query($sql);
  49.  
  50. $response = file_get_contents('https://'. $realmRegion .'.api.battle.net/wow/auction/data/'. $realmName .'?locale=en_GB&apikey=' . $apiKey); $responseObject = json_decode($response, true);
  51. $auctionsFile = file_get_contents($responseObject['files'][0]['url']); $auctionsArray = json_decode($auctionsFile, true)['auctions'];
  52. foreach ($auctionsArray as $auction) { $sql = "INSERT INTO auctions (auc, item, owner, buyout, quantity, context) VALUES(" . $auction['auc'].",". $auction['item'].",'".$auction['owner']."',".$auction['buyout'].",".$auction['quantity'].",".$auction['context'].");"; $conn->query($sql); }
  53. $conn ->query("delete from auctions where buyout=0");
  54.  
  55.  
  56. }
  57.  
  58. } else {
  59. echo "0 results";
  60. }
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement