vermaysha / hoyoapi

HoYoAPI is an unofficial API Wrapper library developed to facilitate communication with the official HoYoLab API.
https://vermaysha.github.io/hoyoapi/
MIT License
68 stars 13 forks source link

cant redeem code #91

Closed yeci226 closed 10 months ago

yeci226 commented 1 year ago

title

jokelbaf commented 1 year ago

What is the problem? Which game? Code? Give more context

MurasakiNX commented 1 year ago

I think it's about Honkai Star Rail, because it returns an error

"System busy. Please try again later. (Error code -1048)"

jokelbaf commented 1 year ago

I think it's about Honkai Star Rail, because it returns an error

"System busy. Please try again later. (Error code -1048)"

I see. The problem is that url for HSR redemption is different from Genshin one.

For star rail: https://sg-hkrpg-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey

For genshin: https://sg-hk4e-api.hoyolab.com/common/apicdkey/api/webExchangeCdkey

You can manually fix that by adding some "if else" logic for url depending on game in module/redeem/redeem.js file.

jokelbaf commented 1 year ago

Here is an example of the temporary fix:

...
const url = this.game === "hkrpg_global" ? "https://sg-hkrpg-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey" : "https://sg-hk4e-api.hoyolab.com/common/apicdkey/api/webExchangeCdkey";
const { response } = await this.request.send(url, "GET", 0);
return response;

I hope either @vermaysha or @wavyflow will finally pay attention and fix tons of bugs in their library...