cchennnn
(autumn chen)
May 24, 2022, 9:44am
1
I have a question about the putific API.
So, I’ve been writing a script to help upload itchio games using this API - the code is at itch_to_ifdb.py · GitHub . I tested this on a local server, which I set up using the instructions at GitHub - iftechfoundation/ifdb: The software behind the Interactive Fiction Database (IFDB) , and it works - I can create new listings with test@ifdb.org , and it also works when I create a new user.
However, when trying to use the same script on the actual IFDB (using http://ifdb.org/putific as the api endpoint), it doesn’t work - I get the error “The IFDB login failed: incorrect username or password.”, even though I know the username (email) and password are correct (unrelated but I guess sending passwords over http is a security risk). I also tried https://ifdb.org/putific , and that gets no response.
Is there any reason why it would work in localhost, but not on the server?
4 Likes
dfabulich
(Dan Fabulich)
October 3, 2022, 4:25am
2
I reproduce the issue with https://ifdb.org/putific and I’ve filed it as
opened 04:23AM - 03 Oct 22 UTC
Launch a local dev environment with Docker at `http://localhost:8080`, then open… Chrome Dev Tools and paste in this script, which uses the https://ifdb.org/api/putific API to automatically submit a game.
```js
const body = new FormData();
body.append('username', 'ifdbadmin@ifdb.org');
body.append('password', 'secret');
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<ifindex version="1.0" xmlns="http://babel.ifarchive.org/protocol/iFiction/">
<story>
<bibliographic>
<title>Test ${Date.now()}</title>
<author>Test Author</author>
</bibliographic>
</story>
</ifindex>
`;
body.append('ifiction', new Blob([xml], {type: 'text/xml'}));
const response = await fetch('/putific', {
method: 'post',
body,
});
const {status, statusText} = response;
const text = await response.text();
console.log(JSON.stringify({status, statusText, text}, null, 2));
```
It works fine on localhost. But now navigate to staging https://dev.ifdb.org or production https://ifdb.org and run the same script. (Replace the username and password with your own email and password.)
You'll see this response on the console:
```
{
"status": 500,
"statusText": "Internal Server Error",
"text": ""
}
```
When I check `/var/log/apache2/error.log` on staging, it says:
`PHP Fatal error: Uncaught Error: Call to undefined function simplexml_load_file() in /var/www/html/putific:108\nStack trace:\n#0 /var/www/html/putific(147): load_xml_file('/tmp/phpNqpyXf', 'iFiction record')\n#1 {main}\n thrown in /var/www/html/putific on line 108, referer: https://dev.ifdb.org/`
I’m investigating now.
2 Likes
dfabulich
(Dan Fabulich)
October 3, 2022, 8:44pm
3
It’s fixed! You can test it by pasting this script into Chrome Dev Tools on ifdb.org , changing the username and password to your email address and password. (If you use it as-is, please navigate to the game you created and click “Delete This Page” to clean up the test game you made.)
const body = new FormData();
body.append('username', 'ifdbadmin@ifdb.org');
body.append('password', 'secret');
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<ifindex version="1.0" xmlns="http://babel.ifarchive.org/protocol/iFiction/">
<story>
<bibliographic>
<title>Test ${Date.now()}</title>
<author>Test Author</author>
</bibliographic>
</story>
</ifindex>
`;
body.append('ifiction', new Blob([xml], {type: 'text/xml'}));
body.append('requireIFID', 'no');
const response = await fetch('/putific', {
method: 'post',
body,
});
const {status, statusText} = response;
const text = await response.text();
console.log(JSON.stringify({status, statusText, text}, null, 2));
1 Like
dfabulich
(Dan Fabulich)
October 5, 2022, 6:18pm
4
I’ve added a few sample scripts to the IFDB Github.
There are three sample scripts there, in Python, Node.js, and Bash/Curl. (The sample scripts also demonstrate how to upload a cover image.)
1 Like