[INFO/WEB] InfoApi v0.2 - a simple API for your Bukkit Server [1060]

Discussion in 'Inactive/Unsupported Plugins' started by Seta, Aug 15, 2011.

  1. Offline


    InfoApi V 0.2

    Info Api provides a simple API for youre Bukkit Server. There may already plugins out there doing that. But this is mine, and because it works great i share it ;)

    Use this Version: http://dev.bukkit.org/server-mods/infoapi/ by Janka
    Possible Api Querys:
    The Player Query only Works with Online Players! It returns as:
    each request needs its secret key at the end like:

    Download Fork me @ Github Nice PHP Script by @Janka

    Config File
    Example Usage PHP
    $apiurl "http://server:25577/onlineplayer"
    $ch curl_init();
    $onlineplayer curl_exec($ch);
    Please note: If the Query is wrong, or the Server cant Handle it, it will appear as "not found website". Also this Plugin will give an Error if you do /reload, because the API Server CAN'T get reloaded at the moment. Thats not really an problem, but you should know. Also there can be an Error on Shutdown... im sorry about that

    If somebody knows how i could convert Minecraft Time to real time, please say ;)

    • V 0.2 - added some functions (cpu/ram/player/chat/kick) & small fixes
    • V 0.1 - releasing this plugin
  2. Offline


    Interesting. Github? I will add some more things.
  3. Offline


    Same. Github?
  4. Offline

    tha d0ctor

    are there any examples of this in use?
  5. Offline


    Omg this is cool! :D Server chat (to display on the website) would be cool aswell! :D
    Also imma join in:

  6. Offline


    Use the Prefix /chat ^^
    But ive got some problems with recreating the Array, so only the first X messages will get shown.

    Also you might already read my end note, the way i do the thread is not optimal.
    Dont Bash me for that xD

    GitHub is ready in a few minutes ;)

    @codename_B @RazorFlint @Pencil
    https://github.com/setamagiga/InfoApi ;)

    Like you will see the Chat Stuff is added, i will be happy to see like you make it better :D

    Did you ever saw an website with no content just a Number or a list of Names?
    Then you know how this will look like, the rest is youre creativity ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
  7. Offline


    missing a changelog
  8. Offline


    i just realized, but you did it first ;)
  9. Offline


    Google Chrome (Yes, since I had my new computer, I switched to it, because I hate how Firefox is on Windows 7.) says it couldn't find the page. I can't prove it it's true if it's down.


    Github pl0x?
  10. Offline


    Github link is up there ^^

    One issue is if you do an Query which would call an error the Socket Stops and starts Again without saying anything to the user. This would look like a not existing page.

    If you get this on every Query i really dont know why... maybe its Chrome (i dont like it very much xD)
    Or, are you sure the Plugin is running? And you use the right Port? Did you Ping it?
  11. Offline

    tha d0ctor

    sweet deal so its pretty much like ApiCraft but with more features?

    thats great, you can make some cool widgets with iframes
  12. Offline


    Theres an example PHP Code, please dont work with iframes!!! xD (thats the web-dev in me :p)

    I didnt know APICraft, his plugin is much richer coded, but yes, less features it seems xD
    Mine seems much more lightweight. Btw i dont really see any point in parsing such less information with json or xml like ApiCraft does :confused:
  13. Offline

    tha d0ctor

    haha I'll avoid iframes, thanks for the PHP code

    would there be any chance to add:
    -ingame time
    -ram usage stats
    -and ping maybe? is ping even possible? I doubt it but if it is that would be cool
  14. Offline


    1: how do you mean that? MineCraft time runs in 24000' i dont really now how to convert this to GMT
    2: Ram usage would be cool yeah :D (accepted :D)
    3: Ping is not really possible, the server would ping it self, this doesnt make sense. But you can do this youre own with PHP (i dont know how, but it *must* be possible, maybe not on shared hosting)

    @Pencil, Chat should work now ;)
    @tha d0ctor, Ram is now includet.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
  15. Offline


  16. Offline


  17. Offline


    no problem ;)
  18. Offline

    tha d0ctor

    great, thanks a ton!
  19. So - because I can't integrate the PHP Code into TYPO3 without spending months on coding an proper T3 Extension here is my "iFrame" Version of the PHP Script provided above. Maybe someone else needs it.



    $_GET['request'])) $request htmlentities($_GET['request'], ENT_QUOTES);

    $request)) {
    $apiurl  "http://example.com:25577/";
    $secret  "wheresmabukkit";
    $askfor  $apiurl $request "?" $secret;
    $result  "";

    $curl  curl_init();

    $result  curl_exec($curl);
        } else {
    "You didn't asked for something";
    As you can see you have to pass the File an GET Parameter in which you state what you want (eg. a command from this plugin). Of course you could also add some fancy security loops to double check if someones trying to mess with this script but I think it is sufficient for most people. It could also be wise to include the secret string as an extra PHP script only readable by the Server Process (eg. www-data or similar).

    To fancy up the result do the "usual stuff" with $result. Means - break the PHP, include some HTML,CSS etc. etc. And when you are finished call it with something like:

    <iframe src="linktofile.php?request=version" title="Server Status" width="200px" height="20px" scrolling="no" frameborder="0"></iframe>
    Hope that might help someone :)

    Aw Crap, I almost forgot:
    Is there a possibility to add an OP Query or even incorporate permissions (query which user are in which group)?
  20. Offline


    Amazing tut dude :D better than i ever had made it xD
    You can query if user is an op with the player query. With permissions, yeah, i really heavily thought about that, but at the moment im really not sure how the future of "all those permission" plugins will look like. The trend seems to bukkit's own permissions, but the most Server owners didnt realize that already xD... So lets watch this a time ^^
  21. Offline


    This code
    $apiurl = "http://URL:25577/maxplayer?pass";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiurl);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
    $res = curl_exec($ch);
    echo $res;
    Doesn't work. I have void at output. May be I use wrong syntax, check it please.

    Oh, sorry!
    I forgot ask you: does it works with craftbukkit 1000?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
  22. I talked to seta about this Problem. It isn't entirely the Plugins fault - cURL treats some of the Output sent over HTTP not as Page because of missing Header Data. To test if the Plugin work let cURL get version. If that does not work then one of 2 Things could have happened:
    1. The Plugin crashed and doesn't want to respond
    2. The Port isn't accessible (usually happens if the server is behind a firewall)
    I am currently reworking the Code for Seta and so far as It seems it will be working in the next Release which will be released as soon as I got some sleep and Seta approves the changes.

    For those who can't wait - i checked v0.3 in on github so you can compile it yourself from there :) it has currently a reduced workset but version and maxplayer should work.
    The other Commands aren't currently configured :) but they will come soon.
  23. This is freakin' awesome, thanks!
  24. Offline


    how can i get cyrilic support in "url/chat?pass"?
  25. Without a Error Message or some additional Information I don't have a Clue why Cyrillic Characters shouldn't work as Secret key / Password? Java uses UTF-16 for Internal Encoding and the Cyrillic Characters are Part of UTF-8 so there shouldn't be a Problem.

    Your Webserver should also use a UTFesque Charset (UTF-8 i suppose) and I couldn't find a Message on the Web that cURL has a Problem with neither UTF-8 nor Cyrillic.

    If your Question was Hypothetical -> then - да - it should work.
  26. Offline


    I have a little probleme :
    there is some query that works and other that don't with your exemple of php use
    deosn't works :
    - onlineplayer(/worldname)
    - maxplayer
    - time
    - onlinemode
    - cpu

    they both work when I'm going directly to the link with my browser but not when i'm using your code ...
    => they all return an integer or a boolean maybe the probleme come from that ? curl can't hadle thoses formats of data ?
    Mihahail likes this.
  27. Offline


    Так ты русский?)
    I have "?" in place of cyrilic symbol when i use /chat?xxx.
    but i testing my php scripts using .bat: php-win.exe test.php >1.txt
    may be my problem here?^^
    equivalent situation! except about browser; browser says "connection closed by server".
    I'm using the example code too.
  28. Well, the Problem is HTTP - because it doesn't know what a Boolean is or lets say - not as this Plugins intends it should know :) If you force a Boolean down the Socket the Browser just shrugs and throws an Error (Page not Found or simply void). Also the Plugin didn't add a HTTP Header to the Result so the Browser generally didn't quite know what to do.

    There is a new Version of this Plugin found here: InfoApi on Bukkitdev or it should be found there. Don't worry - it's still Seta's Plugin but I got Permissions from him to rework the Code so anything will basically stay the same.

    Version 0.3 should AT LEAST send back the String "Not Configured" or if something didn't worked a Standard HTTP 500 Internal Server Error. Currently it only has 3 available Commands :) But I think the full Featureset will be available as late as next monday.

    Also a new reworked PHP Api for the Plugin will be available as soon as I'm finished with it.

    Нет, но я был несколько русских клиентов и могут использовать Google Translate:)

    Well - I think that the .bat is the problem because I think that the Windows Shell uses the "old" ISO Charset while processing so the Characters should be readable when writing it in the file but will be not correctly understood by the php engine.

    When I find some additional Time I will try if non-latin Letters can be used as Secret Key but for now please use latin charaters as key.
  29. Offline


    Ofcourse i allways use latin passwords, becouse this trouble can be anywhere. May be it is my imperfect english, but I means cyrilic symbols in game-chat... Anything my russian users says, I receive as ???????
    So, i'll test it in other way.
  30. Okay so we are Talking about Receiving Things like ChatLog? But all you can see are Question Marks? Well - that's usually a Non-Problem. Just switch the Browsers Charset to UTF-8 and you should see it.
    If they stay Question Marks then maybe you use something like the PHP Command htmlentities? Maybe it replaces the Cyrillic with Question Marks?

    If we Talk about that Minecraft can't display Cyrillic Characters (-> inside the Game) then I fear I cannot help you. It should of course be able to, because MC is written in Java and Java uses UTF-16 as Charset and thus allowing Cyrillic Characters.

Share This Page