fsockopen 10053 error when writing Chars to Java socket

前端 未结 2 1119
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-28 00:21

Right,

I\'m trying to write a wee script in PHP that will send an in game chat package to Minecraft.

//Deliberately low timeout
$mc = fsockopen(\"localho         


        
2条回答
  •  日久生厌
    2021-01-28 00:37

    try the plugin HTTPConsole and

    and use a function like this to execute the command:

    function exec_shell_command($command) {
    $command = urlencode($command);
    $url = "http://127.0.0.1:25560/console?command=$command";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $out = curl_exec($ch);
    curl_close($ch);
    return $out;
    }
    $retval = exec_shell_command("say this is a server message");
    

    I am not sure if this is doing what you want when you say "send a chat message", This posts a console message to the server.

提交回复
热议问题