[Posting] Re: Planetscentral API
From:streu
Thread:Planetscentral API
Forum:Bugs
In reply to:Re: Planetscentral API
Date:Sat, 2023-02-04 15:33 GMT

So geht es in perl jedenfalls nicht :smile:

my $reply = httpCall("GET /dev/playground.cgi/user HTTP/1.0\n", httpBuildQuery(action => 'whoami', api_user => $user, api_password => $pass));

Ich versuche mein Script auf dein c2nu.pl aufzubauen...

Well, you didn't look close enough in browser developer tools :smile: API endpoints are things like "/api/user.cgi".

I just hacked a small PlanetsCentral API client based on c2nu.pl here: https://github.com/stefanreuther/c2nu/blob/c2connect/c2connect.pl

Basically, it can do the same operations that PCC2ng can do (although it can not yet download player files): download the result file from a managed game directory, and upload a turn file for a hosted game.

It happens that the original c2nu.pl has a bug in its httpCall function that generates slightly wrong HTTP requests (\n linefeeds instead of \r\n). Whereas many web servers seem to be flexible here, the web server that runs on PlanetsCentral.com actually insists on the correct format; thus, you'd not get results with the original c2nu.pl version. I fixed that in c2connect.pl.

Disclaimer: c2connect.pl is a proof-of-concept. One important restiction is that it does not do HTTPS, and thus transmits your password in plaintext. At least, avoid it in public wifi.

--Stefan