<?php// change this to wherever you put the thrift library$GLOBALS['THRIFT_ROOT']=dirname(__FILE__)."/thrift";// you have to put your gen-php code into the packages folder$swiftroot=$GLOBALS['THRIFT_ROOT']."/packages";//swiftapi includesrequire_once$swiftroot."/SwiftApi/SwiftApi.php";require_once$swiftroot."/SwiftApi/SwiftApi_types.php";require_once$swiftroot."/Errors/Errors_types.php";//thrift includesrequire_once$GLOBALS['THRIFT_ROOT']."/transport/TSocket.php";require_once$GLOBALS['THRIFT_ROOT']."/transport/TFramedTransport.php";require_once$GLOBALS['THRIFT_ROOT']."/protocol/TBinaryProtocol.php";// Create an authString!functiongetAuthString($methodName){$username="admin";$password="password";$salt="saltines";$toHash=$username.$methodName.$password.$salt;returnhash("sha256",$toHash);}if($_POST){echo"Opening connection...<br />";//open a new connection to the server$socket=newTSocket('your.bukkitserver.org',21111);// note: you must use the TFramedTransport// TBufferedTransport is not compatible with SwiftApi$transport=newTFramedTransport($socket);$protocol=newTBinaryProtocol($transport);echo"Creating client...<br />";//create a new SwiftApiClient object$client=newSwiftApiClient($protocol,$protocol);$transport->open();echo"Server Version: ".$client->getServerVersion(getAuthString("getServerVersion"));//close the connection$transport->close();}?><form action="" method="post"> <input name="submit" type="submit" value="Get Server Version" /></form>
Comments
To post a comment, please login or register a new account.
Comments