Advertisement
Guest User

CURL Minecraft Login PHP

a guest
Nov 29th, 2015
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. $url = 'https://authserver.mojang.com/authenticate/';
  3. $nono = array('\n');
  4. $nonoFix = array('');
  5.  
  6. // LOGIN
  7. echo("Enter your username: ");
  8. $handle = fopen ("php://stdin","r");
  9. $username = str_replace($nono, $nonoFix, fgets($handle));
  10. echo("Enter your password: ");
  11. $password = str_replace($nono, $nonoFix, fgets($handle));
  12.  
  13. // JSON
  14. $agent = array("name" => "Minecraft", "version" => 1);
  15. $object = array("agent" => $agent, "username" => $username, "password" => $password);
  16.  
  17. // CURL
  18. $ch=curl_init();
  19. curl_setopt($ch, CURLOPT_URL, $url);
  20. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  21. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($object));
  23. $result = curl_exec($ch);
  24. curl_close($ch);
  25. echo ("THE AMAZING RESULT ISSSS: " . $result);
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement