alecgorge / jsonapi

A JSON API for Minecraft: http://forums.bukkit.org/threads/admn-info-jsonapi-v1-3-1-json-http-and-socket-api-for-controlling-a-server-740.14270/
http://mcjsonapi.com
MIT License
232 stars 88 forks source link

view_chat how to use it ? #510

Closed Skeeww closed 6 years ago

Skeeww commented 6 years ago

Hey, I want to receive the chat stream over the PHP SDK but I don't know how can I do that, I see there is chat_view but I do what with that ? Thanks

dartasen commented 6 years ago

You need to include this class in your code : https://github.com/alecgorge/jsonapi/blob/master/sdk/php/JSONAPI.php

And in your php code you can put something like :

//Create a new JSONAPI Object
$api = new JSONAPI($host, $port, $uname, $pword);

//Use this method to get the consolelogs in array form
$console = $api->call("getLatestConsoleLogs");
$console = $console["success"];

//Parse the array
foreach($console as $value) {
     $ligne = $value['line'];
      //Do whatever u want
}
Skeeww commented 6 years ago

Yes I know that but I want to have only the tchat not the logs ^^'

dartasen commented 6 years ago

C'est pour ça que dieu a inventé la documentation, elle est faite pour être lue et les développeurs doivent normalement la lire avant d'utiliser une API

Tu retrouves toutes les méthodes que tu peux appeller ici : https://github.com/alecgorge/jsonapi/blob/master/src/resources/methods.json

Celle qui t'intéresse serait donc sûrement celle-ci

{
            "name": "getLatestChats",
            "desc": "Gets up to the last 50 lines in chat. Returned as an array of JSON stream objects.",
            "returns": ["Object[]", "The array of objects"],
            "call": "this.getChatLogs()"
}
Skeeww commented 6 years ago

Merci ^^

dartasen commented 6 years ago

@Skeeww Merci de fermer l'issue si il n'y a plus de problème 💃