Lordieth wrote:Could someone share the technicals on this? Where exactly did it obtain the data? It might be possible just to write a script that does the same thing.
Okay process was as follows
4 user input fields = these would be the nations that were being used for the emquiry - in pipes there was a need to set a default nation purely for testing
This input would be used to create the url to retrieve the data:
Eg Input: Letoilenoir URL created :
http://www.nationstates.net/cgi-bin/api.cgi?nation=letoilenoir
This would return data along the lines of this:
The Chrononauts of Letoilenoir was ranked in the Top 10% of the world for Largest Basket Weaving Sector
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir was ranked in the Top 10% of the world for Largest Retail Industry
Following new legislation in The Chrononauts of Letoilenoir, foreign 'investors' have been taking a great interest in the new secret shuttle
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
+22 more...
It would be the "legislation" line highlighted above that we were interested in so a filter was applied to only let through items containing "legislation"
The "itemPubDate" was the crucial piece of info being the timestamp of the update - The RSS creator was configured to show this info along with a link to the nation and a description of the item
Finally the results were sorted in descending order so that the latest activity was displayed first.
Using this you could quickly compare the update times of up to four regions (eg tracer region, trigger region, target region) and fed into the output.
Going forward It would be logical to assume that using the "legislation" shard of a nation would remove the need for the filter, however this particular shard does not appear to contain a timestamp:
<NATION id="letoilenoir">
<LEGISLATION>
<LAW>
<![CDATA[
a niche industry catering to S&M enthusiasts has sprung up
]]>
</LAW>
<LAW>
<![CDATA[
the nation has welcomed its expats back with open arms
]]>
</LAW>
<LAW>
<![CDATA[
tightly packed choir-boys sing the god-given joys of heterosexuality on public transport
]]>
</LAW>
<LAW>
<![CDATA[
foreign 'investors' have been taking a great interest in the new secret shuttle
]]>
</LAW>
</LEGISLATION>
</NATION>
The "happenings" shard however does:
<NATION id="letoilenoir">
<HAPPENINGS>
<EVENT>
<TIMESTAMP>1434951862</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Largest Basket Weaving Sector.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1434403528</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1434402683</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1430573574</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1430522764</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1427265039</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Largest Retail Industry.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425189299</TIMESTAMP>
<TEXT>
Following new legislation in @@letoilenoir@@, foreign 'investors' have been taking a great interest in the new secret shuttle.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425161794</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425161769</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1424155680</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Most Godforsaken (last census: Top 5%).
</TEXT>
</EVENT>
</HAPPENINGS>
</NATION>
So it would seem that the filter will still be necessary
Effectively then we are looking at four calls to the api to retrieve the "happenings" shard, apply a filter to extract the legislation data, and echo the timestamp (yes I'm thinking php) formatted in a human readable form, and sorting them by most recent to mimic the functionality of the original
My thinking is a form to capture the user input (the four nations) populating an array. Then a foreach loop to call the data from the api -
Echoing and formatting the timestamp should be reasonably straighforward(once I get the fist stage working properly, but the sorting is beyond my scope......at the moment
Input, suggestions and help gladly welcomed