Everybody who has import scripts running as a cronjob, there's this effect that the cronjob is run als guest user. So imported pages via API are created and modified by "guest". This is not nice and can lead to confusion. "What?! How can a guest create this page?"
To avoid this and set the current user via API you can do this at the beginning after bootstrapping PW:
include_once("./index.php");
/**
* Overwrite static user for imports. All created pages will now
* have created and modified user set to "importer" PW user.
* Otherwise API created pages will have the created user "guest"
* -------------------------------------------------------------------------------------
*/
$importerUser = wire("users")->get("importer");
if($importerUser->id) wire()->setFuel("user", $importerUser, $lock = true);
Only thing is you have to create a new superuser with the name you wish to use for such scripts and replace the name in the script.
Now if you run this script no matter from where or with what current user you'll have "importer" as the created and modified user.
-----
Note: There's a new way to set system vars like $user via wire(name, value), but this doesn't seem to work in this case in my tests. Cause the user will get overwritten again when creating a page by the current user calling the script. I'm not sure it's a bug or what, so it might be possible in future to use the shorter version of wire()->setFuel(name, value).