Tom Posted June 25, 2016 Share Posted June 25, 2016 Hi survivors, With version 243.0 the devs implemented the new feature to receive web notifications. It is already implemented here in the forum, but can also be used for private servers. In this tutorial I will show you how to do it. 1) Prepare game server for notifications Make sure you add "-webalarm" to the command line of your start script. If you are running a hosted server with g-portal, nitrado etc. you have to wait until they implement the feature Secondly, you have to create the AlarmPostCredentials.txt file in the /ShooterGame/Saved/ folder 2) Security key and listening script The previously mentioned text file must contain two lines First line has a security key which is optional to use in the listening script, but required to have it in the text file, no matter what it looks like. It can be even "aspojasd" if you want Second line specifies the URL where your listening script is stored, waiting and ready to receive the post information by your game server Example file then would look like this: Th4t5my53cr3tC0d3! http://myurl.com/my_ark_script.php Now you need to setup a script that is able to work with the following HTTP POST which will be send URLencoded: key=Th4t5my53cr3tC0d3!&steamid=76545465465498489489¬etitle=Example%2BTitle&message=Example+Message The message and title are URL encoded, so make sure to decode them in your script 3) Example script As there is no general solution how to deal with the notifications, as you guys all have a different set up for server, database etc, i will just provide you an example script which you can use to modify it further: <?php if($_POST["key"] && $_POST["steamid"] && $_POST["notetitle"] && $_POST["message"]) { $key = urldecode($_POST["key"]); $steamid = urldecode($_POST["steamid"]); $title = urldecode($_POST["notetitle"]); $message = urldecode($_POST["message"]); if ($key == "Th4t5my53cr3tC0d3!") { // Here you can do anything now, since the code is correct and everything else is provided, too. } else echo "Invalid key"; } else echo "Invalid request"; ?> With that script you are now basically able to do nearly anything. You could think of sending your members an e-Mail or chat message in your forum. You could go even further and send them a whatsapp message or anything else, as long as you have implemented the needed API and you are able to link the user's steam ID with an email, cellphone number etc. Enjoy :-) Tom Link to comment Share on other sites More sharing options...
Tom Posted June 25, 2016 Author Share Posted June 25, 2016 Here an example how it could look like: Link to comment Share on other sites More sharing options...
Administrator Chris Posted June 25, 2016 Administrator Share Posted June 25, 2016 That's actually wrong. The data for title is 'notetitle'. Link to comment Share on other sites More sharing options...
Tom Posted June 25, 2016 Author Share Posted June 25, 2016 Fixed it. Link to comment Share on other sites More sharing options...
LastGon Posted June 26, 2016 Share Posted June 26, 2016 Hello ! You are my master ! Many Thanks Link to comment Share on other sites More sharing options...
Toni Posted June 27, 2016 Share Posted June 27, 2016 On 25.6.2016 at 4:28 PM, Tom said: Hi survivors, With version 243.0 the devs implemented the new feature to receive web notifications. It is already implemented here in the forum, but can also be used for private servers. In this tutorial I will show you how to do it. 1) Prepare game server for notifications Make sure you add "-webalarms" to the command line of your start script. If you are running a hosted server with g-portal, nitrado etc. you have to wait until they implement the feature Secondly, you have to create the AlarmPostCredentials.txt file in the /ShooterGame/Saved/ folder 2) Security key and listening script The previously mentioned text file must contain two lines First line has a security key which is optional to use in the listening script, but required to have it in the text file, no matter what it looks like. It can be even "aspojasd" if you want Second line specifies the URL where your listening script is stored, waiting and ready to receive the post information by your game server Example file then would look like this: Th4t5my53cr3tC0d3! http://myurl.com/my_ark_script.php Now you need to setup a script that is able to work with the following HTTP POST which will be send URLencoded: key=Th4t5my53cr3tC0d3!&steamid=76545465465498489489¬etitle=Example%2BTitle&message=Example+Message The message and title are URL encoded, so make sure to decode them in your script 3) Example script As there is no general solution how to deal with the notifications, as you guys all have a different set up for server, database etc, i will just provide you an example script which you can use to modify it further: <?php if($_POST["key"] && $_POST["steamid"] && $_POST["notetitle"] && $_POST["message"]) { $key = urldecode($_POST["key"]); $steamid = urldecode($_POST["steamid"]); $title = urldecode($_POST["notetitle"]); $message = urldecode($_POST["message"]); if ($key == "Th4t5my53cr3tC0d3!") { // Here you can do anything now, since the code is correct and everything else is provided, too. } else echo "Invalid key"; } else echo "Invalid request"; ?> With that script you are now basically able to do nearly anything. You could think of sending your members an e-Mail or chat message in your forum. You could go even further and send them a whatsapp message or anything else, as long as you have implemented the needed API and you are able to link the user's steam ID with an email, cellphone number etc. Enjoy :-) Tom Thanks for the tutorial. As you already seem to have programmed this, can you please answer me the additional questions i have?: - When a tribe is attacked, will there be multiple POSTS to this URL? Will each tribe member be informed about the attack or only the tribe owner or tribe admins? - Whats when someone is attacking our base with for example Quetz + platform + rpg. The tripwire isn't triggered then? Thanks for some additional informations Link to comment Share on other sites More sharing options...
Tom Posted June 27, 2016 Author Share Posted June 27, 2016 If there are multiple posts to the script, there would be multiple actions of course. So if game server posts 10 times, it will send 10 times an email for example (if you specified that an email should be send) Link to comment Share on other sites More sharing options...
Wi1d Posted June 27, 2016 Share Posted June 27, 2016 Thanks for the tutorial! One question I have is how would I invoke a test in game to send an alert to the listening script? I've verified the script is working with manually doing the urlencoded HTTP POST and the script works. However, our ark server hasn't never attempted to do a POST yet. I've tried setting off in game tripwires but I'm not sure what all in-game events will even trip this off. I've double checked -webalarms is enabled and ShooterGame/Saved/AlarmPostCredentials.txt is in place. Thanks again! Link to comment Share on other sites More sharing options...
AsH Posted June 27, 2016 Share Posted June 27, 2016 1 hour ago, Wi1d said: Thanks for the tutorial! One question I have is how would I invoke a test in game to send an alert to the listening script? I've verified the script is working with manually doing the urlencoded HTTP POST and the script works. However, our ark server hasn't never attempted to do a POST yet. I've tried setting off in game tripwires but I'm not sure what all in-game events will even trip this off. I've double checked -webalarms is enabled and ShooterGame/Saved/AlarmPostCredentials.txt is in place. Thanks again! We got the same issue here on Windows Server. Link to comment Share on other sites More sharing options...
Silk Posted June 27, 2016 Share Posted June 27, 2016 For OfficialServers, can you specify an email address for the alert to goto that isn't your forum email address? I ask because I can write a script that will poll a specific email address for these alerts and incorporate them into my app without having the webhook. Link to comment Share on other sites More sharing options...
DrunkMunki Posted June 28, 2016 Share Posted June 28, 2016 I created the below script to save every report into a alarms.txt file but it keeps saying Invalid request Any idea how to fix it? <?php if($_POST["key"] && $_POST["steamid"] && $_POST["notetitle"] && $_POST["message"]) { $key = urldecode($_POST["key"]); $steamid = urldecode($_POST["steamid"]); $title = urldecode($_POST["notetitle"]); $message = urldecode($_POST["message"]); $date = date("d/m/Y h:i:sa"); if ($key == "randomcodehere") { $file = 'alarms.txt'; $content = json_encode($date, $key, $steamid, $title, $message); file_put_contents($file, $content); $content = json_decode(file_get_contents($file), TRUE); } else echo "Invalid key"; } else echo "Invalid request"; ?> Link to comment Share on other sites More sharing options...
Administrator Chris Posted June 28, 2016 Administrator Share Posted June 28, 2016 16 hours ago, Wi1d said: Thanks for the tutorial! One question I have is how would I invoke a test in game to send an alert to the listening script? I've verified the script is working with manually doing the urlencoded HTTP POST and the script works. However, our ark server hasn't never attempted to do a POST yet. I've tried setting off in game tripwires but I'm not sure what all in-game events will even trip this off. I've double checked -webalarms is enabled and ShooterGame/Saved/AlarmPostCredentials.txt is in place. Thanks again! Make sure you're in a tribe on your server and set off the trip alarm in-game. If you have everything setup properly it will send out the POST request. Link to comment Share on other sites More sharing options...
elbarto331 Posted June 28, 2016 Share Posted June 28, 2016 1 hour ago, DrunkMunki said: I created the below script to save every report into a alarms.txt file but it keeps saying Invalid request Any idea how to fix it? <?php if($_POST["key"] && $_POST["steamid"] && $_POST["notetitle"] && $_POST["message"]) { $key = urldecode($_POST["key"]); $steamid = urldecode($_POST["steamid"]); $title = urldecode($_POST["notetitle"]); $message = urldecode($_POST["message"]); $date = date("d/m/Y h:i:sa"); if ($key == "randomcodehere") { $file = 'alarms.txt'; $content = json_encode($date, $key, $steamid, $title, $message); file_put_contents($file, $content); $content = json_decode(file_get_contents($file), TRUE); } else echo "Invalid key"; } else echo "Invalid request"; ?> How did you test your script, From your web browser ? or from a tool like REST Easy ? Link to comment Share on other sites More sharing options...
Toni Posted June 28, 2016 Share Posted June 28, 2016 1 hour ago, DrunkMunki said: I created the below script to save every report into a alarms.txt file but it keeps saying Invalid request Any idea how to fix it? <?php if($_POST["key"] && $_POST["steamid"] && $_POST["notetitle"] && $_POST["message"]) { $key = urldecode($_POST["key"]); $steamid = urldecode($_POST["steamid"]); $title = urldecode($_POST["notetitle"]); $message = urldecode($_POST["message"]); $date = date("d/m/Y h:i:sa"); if ($key == "randomcodehere") { $file = 'alarms.txt'; $content = json_encode($date, $key, $steamid, $title, $message); file_put_contents($file, $content); $content = json_decode(file_get_contents($file), TRUE); } else echo "Invalid key"; } else echo "Invalid request"; ?> If your testing it with a web browser, then you have to replace the POST's with GET's Link to comment Share on other sites More sharing options...
DrunkMunki Posted June 28, 2016 Share Posted June 28, 2016 thanks @Toni using GET works Justa FYI its not adding the data to the text file, will prob need to use fopen .. but thanks for the help Link to comment Share on other sites More sharing options...
elbarto331 Posted June 28, 2016 Share Posted June 28, 2016 7 minutes ago, DrunkMunki said: thanks @Toni using GET works It works for your tests but it won't works with the ARK server. The server send the data over POST so you have to deal with it. If you want to test your script with POSTs I suggest you to use tools such as REST Easy for Firefox or this one for Chrome. Link to comment Share on other sites More sharing options...
DrunkMunki Posted June 28, 2016 Share Posted June 28, 2016 2 minutes ago, elbarto331 said: It works for your tests but it won't works with the ARK server. The server send the data over POST so you have to deal with it. If you want to test your script with POSTs I suggest you to use tools such as RESTEasy for Firefox or this one for Chrome. I understand that, was testing it through the browser to test the code, will change to GET and test once everythings confirmed it should work then right? Link to comment Share on other sites More sharing options...
elbarto331 Posted June 28, 2016 Share Posted June 28, 2016 9 minutes ago, DrunkMunki said: I understand that, was testing it through the browser to test the code, will change to GET and test once everythings confirmed it should work then right? Yes it should. I am also writing an webapp for my servers with Rails, here is the GitHub repo if someone is interested: https://github.com/adenaud/atwan Link to comment Share on other sites More sharing options...
AsH Posted June 28, 2016 Share Posted June 28, 2016 5 hours ago, Casanova said: Make sure you're in a tribe on your server and set off the trip alarm in-game. If you have everything setup properly it will send out the POST request. We setup up everything like it is described here. We started testing that when we saw a Jeremy's guide (http://steamcommunity.com/app/346110/discussions/10/351659808494311902/). But there were no POST requests in access log of web server. What we did in-game on our unofficial server? I was in a tribe and I placed some Tripwire Alarm Traps near wild dinos and was waiting when they pass through them. And nothing as a result. I did more than that. I invited my friend to join (he wasn't in my tribe), I placed some Alarm Traps again, activated a Direwolf's mating process (x500 breeding) and asked my friend to wait for dino baby birth and to pass through the traps when I was offline/online. And nothing again in access log of web server! I saw how this should works on official server, but how to make it possible on unofficial? Could you setup your dedicated server and check this? As we know, Tom didn't do that... Link to comment Share on other sites More sharing options...
Wi1d Posted June 28, 2016 Share Posted June 28, 2016 2 hours ago, AsH said: We setup up everything like it is described here. We started testing that when we saw a Jeremy's guide (http://steamcommunity.com/app/346110/discussions/10/351659808494311902/). But there were no POST requests in access log of web server. What we did in-game on our unofficial server? I was in a tribe and I placed some Tripwire Alarm Traps near wild dinos and was waiting when they pass through them. And nothing as a result. I did more than that. I invited my friend to join (he wasn't in my tribe), I placed some Alarm Traps again, activated a Direwolf's mating process (x500 breeding) and asked my friend to wait for dino baby birth and to pass through the traps when I was offline/online. And nothing again in access log of web server! I saw how this should works on official server, but how to make it possible on unofficial? Could you setup your dedicated server and check this? As we know, Tom didn't do that... Same thing. There isn't anything complicated with the setup. I've followed it to the T and nothing is blocking connectivity between the two servers I'm testing this on yet I never see any incoming POST. I also tried placing tripwires out tripping them myself and having wild dinos trip them to no avail. I also tried placing tripwires around our tribe's base and went offline to see if the event was triggered by being in tribe AND tripwire being triggered AND being offline. Still no POST. Link to comment Share on other sites More sharing options...
Toni Posted June 28, 2016 Share Posted June 28, 2016 2 hours ago, AsH said: We setup up everything like it is described here. We started testing that when we saw a Jeremy's guide (http://steamcommunity.com/app/346110/discussions/10/351659808494311902/). But there were no POST requests in access log of web server. What we did in-game on our unofficial server? I was in a tribe and I placed some Tripwire Alarm Traps near wild dinos and was waiting when they pass through them. And nothing as a result. I did more than that. I invited my friend to join (he wasn't in my tribe), I placed some Alarm Traps again, activated a Direwolf's mating process (x500 breeding) and asked my friend to wait for dino baby birth and to pass through the traps when I was offline/online. And nothing again in access log of web server! I saw how this should works on official server, but how to make it possible on unofficial? Could you setup your dedicated server and check this? As we know, Tom didn't do that... The same here. No POST to the URL. Seems to need a fix on wildcards side? Does the .txt really has to be located in ShooterGame/Saved/ ? Or does it maybe should be in /ShooterGame/Saved/Config/ ? Link to comment Share on other sites More sharing options...
Administrator Chris Posted June 28, 2016 Administrator Share Posted June 28, 2016 Has anyone in this thread actually SEEN their unofficial server sending out the POST request? Link to comment Share on other sites More sharing options...
Toni Posted June 28, 2016 Share Posted June 28, 2016 1 hour ago, Casanova said: Has anyone in this thread actually SEEN their unofficial server sending out the POST request? Still trying to get that to work... no success till now. Unfortunately my hoster does not provide access logs. I can only test it manually (by changing the POST to GET) and there all is ok. So seems like the Ark server does not send the post request. Does it need to be an SSL URL (https) ? Is there something we have to consider which is not described in this post or in the steam forum post? Link to comment Share on other sites More sharing options...
Wi1d Posted June 28, 2016 Share Posted June 28, 2016 40 minutes ago, Toni said: Still trying to get that to work... no success till now. Unfortunately my hoster does not provide access logs. I can only test it manually (by changing the POST to GET) and there all is ok. So seems like the Ark server does not send the post request. Does it need to be an SSL URL (https) ? Does we have to use an URL in the .txt file which already has a "?" and some parameters in it? Is there something we have to consider which is not described in this post or in the steam forum post? It doesn't have to use an SSL URL according to this how to it just needs to be POST. You can test your script out using POST w/ something like Fiddler or someone mentioned a FF plugin as well. Since we are using POST, you shouldn't need any "?" parameters unless you've added something into your script that would find them useful. Of course take this with a grain of salt since I still can't get the ark server to send POST but at least you can test your script. Here's an example of my testing if it helps using Fiddler Link to comment Share on other sites More sharing options...
elbarto331 Posted June 28, 2016 Share Posted June 28, 2016 Not working for me as well, I even tried with curl directly from my ark dedicated server. My web hook def create notification = Notification.new notification.uuid = SecureRandom.uuid notification.key = params[:key] notification.steamid = params[:steamid] notification.notetitle = params[:notetitle] notification.message = params[:message] notification.save render json: {:status => 'OK'} end And my try with curl curl -F "key=key" http://myawesomeserver.com/atwan/notification {"status":"OK"} And rails log : I, [2016-06-28T20:13:24.006375 #11864] INFO -- : Started POST "/notification" for 192.168.0.1 at 2016-06-28 20:13:24 +0200 I, [2016-06-28T20:13:24.050209 #11864] INFO -- : Processing by NotificationController#create as */* I, [2016-06-28T20:13:24.050305 #11864] INFO -- : Parameters: {"key"=>"key"} D, [2016-06-28T20:13:24.051566 #11864] DEBUG -- : (0.2ms) BEGIN D, [2016-06-28T20:13:24.053346 #11864] DEBUG -- : SQL (0.4ms) INSERT INTO "notifications" ("uuid", "key", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["uuid", "a4d3b6ca-6c8c-46dc-8feb-abe5b0202510"], ["key", "key"], ["created_at", "2016-06-28 18:13:24.051765"], ["updated_at", "2016-06-28 18:13:24.051765"]] D, [2016-06-28T20:13:24.063048 #11864] DEBUG -- : (9.3ms) COMMIT I, [2016-06-28T20:13:24.063700 #11864] INFO -- : Completed 200 OK in 13ms (Views: 0.3ms | ActiveRecord: 9.9ms) But nothing from the game, (I am in a Tribe and my friend wasn't) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.