Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Posting trade information back to TTC #1

Open
kevinlekiller opened this issue Sep 27, 2019 · 4 comments
Open

Posting trade information back to TTC #1

kevinlekiller opened this issue Sep 27, 2019 · 4 comments

Comments

@kevinlekiller
Copy link
Owner

https://us.tamrieltradecentre.com/pc/Trade/WebClient

As seen there, there's an API which receives the information:

static PostTrade(tradeModels) {
	return __awaiter(this, void 0, void 0, function* () {
		if (tradeModels.length == 0)
			return null;
		const resultString = yield HttpService.PostJsonAsync("/api/PC/Trade/PostTrade", tradeModels);
		const bulkPostTradeResult = JSON.parse(resultString);
		return bulkPostTradeResult;
	});
}
@kevinlekiller
Copy link
Owner Author

kevinlekiller commented Sep 27, 2019

Instead of porting the webclient, maybe use phantomjs to upload the lua file.

This is the input form on the webclient for the lua file:

<input name="SavedVarFileInput" type="file" accept=".lua" data-bind="visible: !IsBusy()" style="">

@kevinlekiller
Copy link
Owner Author

kevinlekiller commented Sep 27, 2019

Something like this?

var page = require('webpage').create();
page.open('https://us.tamrieltradecentre.com/pc/Trade/WebClient', function(status) {
	if (status !== 'success') {
		console.log('Unable to access network');
	} else {
		page.uploadFile('input[name=SavedVarFileInput]', 'TamrielTradeCentre.lua');
		page.evaluate(function(){
			document.forms[0].submit();
		});
		page.render('testForm.png');
	}
	phantom.exit();
});

@kevinlekiller
Copy link
Owner Author

The web client itself seems non functional - even after logging in the data is not sent to their server.

I've installed fiddler and run the windows program to see what data is sent to the server.

Here is the info, it should be enough to write a client:

https://gist.github.com/kevinlekiller/18bffce265bdd0694b531b288d4c6bac

Also their API gives info on the price table version which can prevent us from downloading it if it's already up to date:

https://us.tamrieltradecentre.com/api/GetTradeClientVersion

@kevinlekiller
Copy link
Owner Author

I've written a lua script to parse the data, but when I try to send it to the API it refuses to take the data, I've tried various headers to no success, maybe someone else can figure it out:

https://gist.github.com/kevinlekiller/40c94d87321c64547c9e5a4b629718d9

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant