NATION

PASSWORD

NationStates API (nationdata/regiondata)

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.

Advertisement

Remove ads

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Fri Jan 24, 2014 8:06 pm

[violet] wrote:
Shadow Afforess wrote:*cough*cough* so [violet] where is the new API to retrieve factbook/dispatches? >:(

Did I promise one? Your grumpy face makes me think I agreed to do something, but I don't see a request in this thread...


It was an implied request. Obviously, every new site feature deserves an API! :palm:
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Tlik
Ambassador
 
Posts: 1253
Founded: Jan 31, 2009
Ex-Nation

Postby Tlik » Sat Jan 25, 2014 1:19 am

[violet] wrote:
Shadow Afforess wrote:*cough*cough* so [violet] where is the new API to retrieve factbook/dispatches? >:(

Did I promise one? Your grumpy face makes me think I agreed to do something, but I don't see a request in this thread...

You promise us things with your kindness and constant stream of improvements. You need to be harsher and more vicious! We mere players have no right to expect you to do things for us! I recommend withholding all new features for the next six months to teach us all a lesson... :P

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Sat Jan 25, 2014 1:34 am

Tlik wrote:
[violet] wrote:Did I promise one? Your grumpy face makes me think I agreed to do something, but I don't see a request in this thread...

You promise us things with your kindness and constant stream of improvements. You need to be harsher and more vicious! We mere players have no right to expect you to do things for us! I recommend withholding all new features for the next six months to teach us all a lesson... :P


You fool! That's been the status quo for years! Only the constant stream of tweaks from NS++ has changed player expectations! You'll undo almost a year of hard work! ;)
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Liberal Sweedish and French Unity
Spokesperson
 
Posts: 137
Founded: Dec 30, 2013
Ex-Nation

Postby Liberal Sweedish and French Unity » Mon Jan 27, 2014 9:53 am

I've got a API key, with no idea how it works. Im not very technical. :) :)
Hi, I'm Liberal Sweedish and French Unity. Don't disrespect my nations way of spelling Sweden, it makes it unique.
PRO: Liberal, no 1p, EU, UN, Sweden, France, Italy, Conservative, M. Thatcher, N.Mandela, Christian
ANTI: 1P, David Cameron and a lot more!
Ive tried to make a issue 1 add 1 equels 3. Is this the longest sig.

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Thu Feb 06, 2014 6:44 pm

I am trying to use an API template for my first time, for the purpose of recruiting for my region, but when I tried to send it, it said:

Client Not Registered For API

Error: 403 Client Not Registered For API
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Thu Feb 06, 2014 7:08 pm

Nephmir wrote:I am trying to use an API template for my first time, for the purpose of recruiting for my region, but when I tried to send it, it said:

Client Not Registered For API

Error: 403 Client Not Registered For API

You need to request a client key from the moderators. Use a getting-help request. See the FAQ if you are unsure how to do this.
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Fri Feb 07, 2014 4:03 am

Okay, thanks!
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Fri Feb 07, 2014 6:49 am

I received the key, but it still says the same error when I try to send it.
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
The Black Hat Guy
Diplomat
 
Posts: 952
Founded: Feb 12, 2013
Ex-Nation

Postby The Black Hat Guy » Fri Feb 07, 2014 8:12 am

Nephmir wrote:I received the key, but it still says the same error when I try to send it.


Did you put the correct key into the correct location in the API call?

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Fri Feb 07, 2014 4:29 pm

It wouldn't even let me get that far. I clicked the link below where it said "you can test this by sending one to yourself:", and it said I was unregistered.
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Fri Feb 07, 2014 8:08 pm

Nephmir wrote:It wouldn't even let me get that far. I clicked the link below where it said "you can test this by sending one to yourself:", and it said I was unregistered.


That is just an example of the FORMAT of the url. You need to replace the query variables with the client key, telegram id, and secret id.
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Postby Nephmir » Sat Feb 08, 2014 4:29 am

Shadow Afforess wrote:
Nephmir wrote:It wouldn't even let me get that far. I clicked the link below where it said "you can test this by sending one to yourself:", and it said I was unregistered.


That is just an example of the FORMAT of the url. You need to replace the query variables with the client key, telegram id, and secret id.

And put it in the url search bar?
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
The Black Hat Guy
Diplomat
 
Posts: 952
Founded: Feb 12, 2013
Ex-Nation

Postby The Black Hat Guy » Sat Feb 08, 2014 7:32 am

Nephmir wrote:
Shadow Afforess wrote:
That is just an example of the FORMAT of the url. You need to replace the query variables with the client key, telegram id, and secret id.

And put it in the url search bar?


Well... Sort of, if you want to send just one telegram I suppose that would work. The API is more for use with scripting, using a program to send multiple telegrams. If you just want to send one you may as well use the regular telegram system.

If you don't know how to program, the only currently publicly released program to access the API is Auralia's, posted here in Technical. Otherwise, Codecademy has a nice Python course available if you'd like to make your own script.

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Sat Feb 08, 2014 11:51 am

The Black Hat Guy wrote:
Nephmir wrote:And put it in the url search bar?


If you don't know how to program, the only currently publicly released program to access the API is Auralia's, posted here in Technical. Otherwise, Codecademy has a nice Python course available if you'd like to make your own script.


Nah, you forgot http://nspostmaster.com/mass_telegram.html
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Mousebumples
Game Moderator
 
Posts: 8623
Founded: Antiquity
Inoffensive Centrist Democracy

Postby Mousebumples » Tue Feb 11, 2014 10:12 pm

Scripting legality query, in light of the recent recruiting changes ...

With regards to the rules for scripts interacting with /page=telegram :

If the script were to add a button (say, next to the address bar on the telegram page) that, when clicked, automatically fills in the name of the next newest nation, would that count as "minor functionality" or would it be an illegal script? (i.e. the page loads normally, button is clicked and that nation's name is filled in, but the player still needs to type up the recruiting TG, etc.)

Thanks for whatever clarification you can provide!
Leader of the Mouse-a-rific Mousetastic Moderator Mousedom of Mousebumples
Past WA Delegate for Europeia & Monkey Island
Proud Member of UNOG
I'm an "adorably marvelous NatSov" - Mallorea and Riva
GA Resolutions (sorted by category) | Why Repeal? | Reppy's Sig Workshop

User avatar
Upska
Lobbyist
 
Posts: 21
Founded: Aug 30, 2011
Psychotic Dictatorship

Umlaut in XML

Postby Upska » Fri Feb 14, 2014 3:45 pm

Recently I decided to write a little PHP script that would fetch the XMLs from some nations. So far the program works fine and manages to save the necessary information from the fetched XMLs, but a few errors appear at the XMLs of two specific nations: Grodka and North-West-Rhein-Failure. After a little research I removed some shards and yes, it was what I expected:

Warning: simplexml_load_file(): http://www.nationstates.net/cgi-bin/api ... ency&v=4:1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xF6 0x72 0x6B 0x61 in C:\xampp\htdocs\charts\update.php on line 15


When looking in their XMLs I find an umlaut at the indicated spot, clearly not with the right encoding. Now, my question is: how do I fix this so that my script can still fetch this info?

User avatar
The Blaatschapen
Technical Moderator
 
Posts: 63226
Founded: Antiquity
Anarchy

Postby The Blaatschapen » Fri Feb 14, 2014 3:57 pm

Upska wrote:Recently I decided to write a little PHP script that would fetch the XMLs from some nations. So far the program works fine and manages to save the necessary information from the fetched XMLs, but a few errors appear at the XMLs of two specific nations: Grodka and North-West-Rhein-Failure. After a little research I removed some shards and yes, it was what I expected:

Warning: simplexml_load_file(): http://www.nationstates.net/cgi-bin/api ... ency&v=4:1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xF6 0x72 0x6B 0x61 in C:\xampp\htdocs\charts\update.php on line 15


When looking in their XMLs I find an umlaut at the indicated spot, clearly not with the right encoding. Now, my question is: how do I fix this so that my script can still fetch this info?


Don't state that the XML is in UTF-8, but rather in another encoding?
The Blaatschapen should resign

User avatar
Upska
Lobbyist
 
Posts: 21
Founded: Aug 30, 2011
Psychotic Dictatorship

Postby Upska » Fri Feb 14, 2014 4:06 pm

The Blaatschapen wrote:
Upska wrote:Recently I decided to write a little PHP script that would fetch the XMLs from some nations. So far the program works fine and manages to save the necessary information from the fetched XMLs, but a few errors appear at the XMLs of two specific nations: Grodka and North-West-Rhein-Failure. After a little research I removed some shards and yes, it was what I expected:



When looking in their XMLs I find an umlaut at the indicated spot, clearly not with the right encoding. Now, my question is: how do I fix this so that my script can still fetch this info?


Don't state that the XML is in UTF-8, but rather in another encoding?


Nowhere do I state in which encoding the XML is, and I believe the function simplexml_load_file can only handle UTF-8. I also have no idea how to change the file to correct UTF-8 encoding, as neither
Code: Select all
<?php
simplexml_load_file(utf8_encode($url));
// nor
simplexml_load_file(mb_convert_encoding($url, 'UTF-8"));
?>


seem to work.

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Sun Feb 16, 2014 7:26 pm

Uh, so who was the genius who reset the event id counting for happenings? It was up to 14469023 and got reset back to zero on 2014-02-09 02:27:04 UTC. Not cool. Repeating ids are not cool. Fortunately I wasn't using it as an index, but it did cause me to not record 8 days worth of data. >:(
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Themightymanuel
Bureaucrat
 
Posts: 41
Founded: May 15, 2013
Ex-Nation

Postby Themightymanuel » Wed Feb 19, 2014 9:07 am

So I am working on designing a Telegram API tool. Yesterday was my first chance to test it out and it worked fine for hours sending recruitment telegrams but today it keeps throwing 404 server not found errors on the nation API requests.
Believe in strong government? Join the Imperium of the Wolf

User avatar
Themightymanuel
Bureaucrat
 
Posts: 41
Founded: May 15, 2013
Ex-Nation

Postby Themightymanuel » Wed Feb 19, 2014 11:42 am

It all seems to be working now.
Believe in strong government? Join the Imperium of the Wolf

User avatar
[violet]
Executive Director
 
Posts: 16205
Founded: Antiquity

Postby [violet] » Wed Feb 19, 2014 4:19 pm

Upska wrote:Now, my question is: how do I fix this so that my script can still fetch this info?

You are in luck! We already have a UTF-8 version in testing. Simply change the API version number you're requesting from 4 to 5. Example:

http://www.nationstates.net/cgi-bin/api ... rrency&v=5

Same data, different encoding.

User avatar
[violet]
Executive Director
 
Posts: 16205
Founded: Antiquity

Postby [violet] » Wed Feb 19, 2014 4:27 pm

Shadow Afforess wrote:Uh, so who was the genius who reset the event id counting for happenings? It was up to 14469023 and got reset back to zero on 2014-02-09 02:27:04 UTC. Not cool. Repeating ids are not cool. Fortunately I wasn't using it as an index, but it did cause me to not record 8 days worth of data. >:(

We had a major downtime incident which corrupted the Happenings data (despite it being in a 4-volume RAID array). I was not able to restore it.

User avatar
Shadow Afforess
Ambassador
 
Posts: 1270
Founded: Nov 06, 2013
Ex-Nation

Postby Shadow Afforess » Wed Feb 19, 2014 4:31 pm

[violet] wrote:
Shadow Afforess wrote:Uh, so who was the genius who reset the event id counting for happenings? It was up to 14469023 and got reset back to zero on 2014-02-09 02:27:04 UTC. Not cool. Repeating ids are not cool. Fortunately I wasn't using it as an index, but it did cause me to not record 8 days worth of data. >:(

We had a major downtime incident which corrupted the Happenings data (despite it being in a 4-volume RAID array). I was not able to restore it.


Alright. That's very unfortunate. At least I am prepared for the unthinkable next time. :(
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.

User avatar
Lad Wolf
Civil Servant
 
Posts: 10
Founded: Feb 15, 2014
Ex-Nation

Postby Lad Wolf » Sun Feb 23, 2014 12:09 pm

If I could make a suggestion:

Since the regions.xml daily data dump has value "0" for a never-existed founder, could you have http://www.nationstates.net/cgi-bin/api.cgi?nation=0&q=endorsements and similar shards for that value ("0") return an error instead of a broken XML tree?

I understand in the future I could either simply change the "0" to something else when querying the API to generate my own consistent error or tell my script to do something when getting the broken tree, but I feel like the correction should be done server side instead of it returning blanks that can then push tables people are creating out of order. :?

Just to clarify again, "0" means it never existed not it is non-existent, I feel like that deserves its own specific error message.

Example regions would the any of the GCRs or regions created very early, like The Proletariat Coalition.
Last edited by Lad Wolf on Sun Feb 23, 2014 12:26 pm, edited 2 times in total.

PreviousNext

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Cyptopir, Ezaekia, Heromerland, IC-Water, ImSaLiA, Mallansaia, Merulla, Mordhaus, Osagh, Radicalania, Reyo, The Southern Dependencies, Tomie

Advertisement

Remove ads