Search the Community
Showing results for tags 'yaml'.
-
Hello! I know this seems like an easy task, using strval or casting to string, but the API I am using WON'T accept anything but a hard coded string "". I figure there has to be a way to get around this... What I have here is a method used to convert an array in to a YAML/String format for me to upload onto a server using JSONAPI, found here. I am using Spyc, as that is the only thing I have found that works for this, and it does pretty well. function pushArrayToServer($array, $api) { $yaml = Spyc::YAMLDump($array,4,60); $value = 0; while (strpos($yaml, "$value:") !== false) { $yaml = str_replace("$value:", "-", $yaml); $value = $value + 1; } $yaml = str_replace("---", "", $yaml); // Final YAML from Array var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml))); } Now the problem is that last $api->call I do. This call accepts the method type as a string(argument 1), and an array for argument two. For the method "files.write", the api requires an array being (file location, string). The string is what will be replacing the content of the file. But the only way I can get that line to work is if I do this: var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", "a string here"))); That works 100% fine, no errors. This is the dump I get when I run that. But as soon as I do one of these: var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml))); $yaml2 = $yaml . ""; var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml2))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", strval($yaml)))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", "$yaml2"))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", (string)$yaml))); These do not work. The dumps all return null. I haven't found a way yet to not do "". It almost worked once when I attempted some things, but I found out I was just converting a boolean into a string which caused an error. The server I am working with is a minecraft server with JSONAPi installed. It works great, except for this error. So I am assuming the string type has to be just like Java's, or pretty plain? I have no clue this is the first real issue I've had with this plugin. Thanks in advance, HeyAwesomePeople