diff --git a/package.json b/package.json index 5901f7d..4616406 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,7 @@ "sharp": "^0.29.2", "simple-markdown": "^0.7.2", "tweenjs": "^1.0.2", - "typescript": "^4.4.4", - "xmlrpc": "^1.3.2" + "typescript": "^4.4.4" }, "scripts": { "prepare": "husky install", diff --git a/src/server/load-pet-data.js b/src/server/load-pet-data.js index c8db65c..bb520ab 100644 --- a/src/server/load-pet-data.js +++ b/src/server/load-pet-data.js @@ -1,23 +1,22 @@ -import util from "util"; import fetch from "node-fetch"; -import xmlrpc from "xmlrpc"; -const neopetsXmlrpcClient = xmlrpc.createSecureClient({ - host: "www.neopets.com", - path: "/amfphp/xmlrpc.php", -}); -const neopetsXmlrpcCall = util - .promisify(neopetsXmlrpcClient.methodCall) - .bind(neopetsXmlrpcClient); +async function neopetsAmfphpCall(methodName, args) { + const url = + "https://www.neopets.com/amfphp/json.php/" + + encodeURIComponent(methodName) + + "/" + + args.map(encodeURIComponent).join("/"); + return await fetch(url).then((res) => res.json()); +} export async function loadPetMetaData(petName) { - const response = await neopetsXmlrpcCall("PetService.getPet", [petName]); + const response = await neopetsAmfphpCall("PetService.getPet", [petName]); return response; } export async function loadCustomPetData(petName) { try { - const response = await neopetsXmlrpcCall("CustomPetService.getViewerData", [ + const response = await neopetsAmfphpCall("CustomPetService.getViewerData", [ petName, ]); return response;