twitter-openapi-typescript 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,12 +2,20 @@
2
2
  "jest.autoRun": {
3
3
  "watch": false
4
4
  },
5
+ "[json]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
7
+ },
8
+ "[jsonc]": {
9
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
10
+ },
11
+ "[yaml]": {
12
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
13
+ },
14
+ "[markdown]": {
15
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
16
+ },
5
17
  "[typescript]": {
6
18
  "editor.defaultFormatter": "esbenp.prettier-vscode",
7
- "editor.codeActionsOnSave": {
8
- "source.fixAll": "explicit",
9
- "source.organizeImports": "explicit",
10
- },
11
19
  "editor.formatOnSave": true,
12
20
  },
13
21
  }
package/README.md CHANGED
@@ -14,8 +14,13 @@ import { TwitterOpenApi } from 'twitter-openapi-typescript';
14
14
  const api = new TwitterOpenApi();
15
15
  const client = await api.getGuestClient();
16
16
  const response = await client.getUserApi().getUserByScreenName({ screenName: 'elonmusk' });
17
- console.log(response.data.legacy.screenName);
18
- console.log(`followCount: ${response.data.legacy.friendsCount} followersCount: ${response.data.legacy.followersCount}`);
17
+ const userLegacy = response.data?.user?.legacy;
18
+ if (userLegacy) {
19
+ console.log(userLegacy.screenName);
20
+ console.log(`followCount: ${userLegacy.friendsCount} followersCount: ${userLegacy.followersCount}`);
21
+ } else {
22
+ console.log('User not found');
23
+ }
19
24
  ```
20
25
 
21
26
  ### Login
@@ -28,10 +33,22 @@ const client = await api.getClientFromCookies({
28
33
  });
29
34
  ```
30
35
 
36
+ ### Multiple OS
37
+
38
+ The Token can only be used on the same OS that issued the Token
39
+ In other words, if the sec-ch-ua-platform does not match, the Token cannot be used.
40
+ This library uses the Linux Chrome header by default.
41
+ To use Token issued by Windows, do the following.
42
+
43
+ ````typescript
44
+ TwitterOpenApi.additionalApiHeaders = {
45
+ 'sec-ch-ua-platform': '"Windows"',
46
+ };
47
+ ```
48
+
31
49
  ### List of APIs
32
50
 
33
51
  You should read the Test case.
34
- aaaaa
35
52
 
36
53
  <https://github.com/fa0311/twitter-openapi-typescript/tree/master/twitter-openapi-typescript/test/api>
37
54
 
@@ -41,13 +58,10 @@ Most values exist as static variables. There is no need to change them.
41
58
 
42
59
  ```typescript
43
60
  import { TwitterOpenApi } from 'twitter-openapi-typescript';
44
- TwitterOpenApi.url = 'twitter-openapi placeholder json url';
45
- TwitterOpenApi.twitter = 'twitter first access url';
46
- TwitterOpenApi.userAgent = 'user agent';
47
- TwitterOpenApi.bearer = 'bearer token';
48
- TwitterOpenApi.browser_headers = 'browser headers';
49
- TwitterOpenApi.api_key = 'api key';
50
- ```
61
+ TwitterOpenApi.additionalBrowserHeaders = {};
62
+ TwitterOpenApi.additionalApiHeaders = {};
63
+ TwitterOpenApi.fetchApi = fetch.bind(globalThis);
64
+ ````
51
65
 
52
66
  ## License
53
67