akameco / pixiv-app-api

Promise base pixiv API client
https://www.npmjs.com/package/pixiv-app-api
MIT License
218 stars 29 forks source link

another "status code 400" #25

Closed airosB closed 4 years ago

airosB commented 5 years ago

Do you want to request a feature or report a bug?: bug

What is the current behavior?:

const pixiv = new PixivAppApi(id, password);
pixiv.login(); // 200 ok
await pixiv.userDetail(123456); // Error: Request failed with status code 400

v1.0.2で一旦400が出なくなりましたが、本日試したところ再度400となっています。 以前と違いlogin() の時点ではエラーにならず、 userDetails や illustSearch などのメソッドを実行した際に400が返ってきます。

What is the expected behavior?: api should return 200 ok

Suggested solution: API has another braking-changes?

Mikubill commented 5 years ago

(日本語下手)エラーは特定なメソッドに限り?エラーメッセージとかより詳しい説明をご提供お願いします。

Can you provide details of the error (eg response content, network/system environment)?

austinhuang0131 commented 5 years ago
const PixivAppApi = require("pixiv-app-api")
const pixiv = new PixivAppApi({camelcaseKeys: false});

pixiv.login("username", "password").then(p => {
  pixiv.userDetail(123456).then(console.log);
});

This is working for me.

airosB commented 5 years ago

I tested again and found this was not a bug, but "Usage" section of readme.md was simply incorrect.

const test = async () => {
    const PixivAppApi = require("pixiv-app-api");
    const pixivImg = require("pixiv-img");
    const pixiv = new PixivAppApi(id, pass)

    // without this line, I got a 400 error.
    await pixiv.login();

    ;(async () => {
      const json = await pixiv.searchIllust('艦これ10000users入り')
      await pixivImg(json.illusts[1].imageUrls.large)
      console.log('finish')
    })();
}

test();

this is ok

await pixiv.login(); 

and this gets 400

pixiv.login();