bb-fca 2.0.4 → 2.0.7

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.
Files changed (38) hide show
  1. package/dist/deltas/apis/create.js +22 -0
  2. package/dist/deltas/apis/create.js.map +1 -1
  3. package/dist/deltas/apis/posting/group.js +607 -0
  4. package/dist/deltas/apis/posting/group.js.map +1 -0
  5. package/dist/deltas/apis/posting/post.js +346 -1
  6. package/dist/deltas/apis/posting/post.js.map +1 -1
  7. package/dist/deltas/apis/posting/story.js +147 -0
  8. package/dist/deltas/apis/posting/story.js.map +1 -1
  9. package/dist/deltas/apis/threads/searchGroup.js +159 -0
  10. package/dist/deltas/apis/threads/searchGroup.js.map +1 -0
  11. package/dist/deltas/apis/users/searchGroups.js +221 -0
  12. package/dist/deltas/apis/users/searchGroups.js.map +1 -0
  13. package/dist/index.d.ts +66 -0
  14. package/dist/types/deltas/apis/create.d.ts +22 -0
  15. package/dist/types/deltas/apis/posting/group.d.ts +90 -0
  16. package/dist/types/deltas/apis/posting/post.d.ts +7 -0
  17. package/dist/types/deltas/apis/posting/story.d.ts +21 -0
  18. package/dist/types/deltas/apis/threads/searchGroup.d.ts +15 -0
  19. package/dist/types/deltas/apis/users/searchGroups.d.ts +17 -0
  20. package/dist/types/utils/axios.d.ts +1 -0
  21. package/dist/types/utils/index.d.ts +1 -0
  22. package/dist/utils/axios.js +12 -0
  23. package/dist/utils/axios.js.map +1 -1
  24. package/dist/utils/index.js +1 -0
  25. package/dist/utils/index.js.map +1 -1
  26. package/package.json +1 -1
  27. package/request.txt +60 -0
  28. package/src/deltas/apis/create.ts +25 -0
  29. package/src/deltas/apis/posting/group.ts +754 -0
  30. package/src/deltas/apis/posting/post.ts +439 -1
  31. package/src/deltas/apis/posting/story.ts +147 -0
  32. package/src/types/index.d.ts +66 -0
  33. package/src/utils/axios.ts +19 -0
  34. package/src/utils/index.ts +1 -0
  35. package/LICENSE-MIT +0 -21
  36. package/examples/post.example.js +0 -149
  37. package/friend.html +0 -534
  38. package/proflie.html +0 -527
@@ -123,6 +123,15 @@ export interface UploadPhotoResult {
123
123
  data: any;
124
124
  }
125
125
 
126
+ export interface UploadVideoResult {
127
+ success: boolean;
128
+ videoID: string;
129
+ uploadID: string;
130
+ uploadSessionID: string;
131
+ fileHandle: string;
132
+ data: any;
133
+ }
134
+
126
135
  export interface ChangeNameResult {
127
136
  /** Raw preview response data from AccountsCenter name validation query. */
128
137
  preview: any;
@@ -365,6 +374,56 @@ export interface ThreadInfo {
365
374
  };
366
375
  }
367
376
 
377
+ export interface SearchGroupOptions {
378
+ limit?: number;
379
+ cursor?: string | null;
380
+ locale?: string;
381
+ }
382
+
383
+ export interface SearchGroupItem {
384
+ groupID: string | null;
385
+ name: string | null;
386
+ url: string | null;
387
+ profileUrl: string | null;
388
+ imageSrc: string | null;
389
+ summary: string | null;
390
+ privacy: string | null;
391
+ memberText: string | null;
392
+ memberCount: number | null;
393
+ joinState: string | null;
394
+ hasMembershipQuestions: boolean | null;
395
+ }
396
+
397
+ export interface SearchGroupResult {
398
+ groups: SearchGroupItem[];
399
+ cursor: string | null;
400
+ hasNextPage: boolean;
401
+ }
402
+
403
+ export interface GroupModule {
404
+ join(groupID: string): Promise<any>;
405
+ leave(groupID: string): Promise<any>;
406
+ getJoinedGroups(
407
+ cursor?: string | null,
408
+ count?: number,
409
+ ): Promise<{
410
+ groups: Array<{
411
+ id: string;
412
+ name: string;
413
+ imageUri: string;
414
+ url: string;
415
+ memberCount: string;
416
+ privacy: string;
417
+ }>;
418
+ endCursor: string | null;
419
+ hasNextPage: boolean;
420
+ }>;
421
+ searchGroup(
422
+ keyword: string,
423
+ options?: SearchGroupOptions,
424
+ ): Promise<SearchGroupResult>;
425
+ }
426
+
368
427
  export interface MessageObject {
369
428
  body?: string;
370
429
  attachment?: ReadStream[];
@@ -606,6 +665,10 @@ export interface API {
606
665
  photoPath: string,
607
666
  callback?: Callback<UploadPhotoResult>,
608
667
  ): Promise<UploadPhotoResult>;
668
+ uploadVideo(
669
+ videoPath: string,
670
+ callback?: Callback<UploadVideoResult>,
671
+ ): Promise<UploadVideoResult>;
609
672
  };
610
673
 
611
674
  /** Comment on a Facebook post. */
@@ -839,6 +902,9 @@ export interface API {
839
902
  /** Add an external module to extend the API. */
840
903
  addExternalModule(moduleObj: Record<string, Function>): void;
841
904
 
905
+ /** Group-related API methods. */
906
+ group: GroupModule;
907
+
842
908
  /** Allow accessing dynamically loaded methods. */
843
909
  [key: string]: any;
844
910
  }
@@ -175,4 +175,23 @@ export async function postFormData(
175
175
  return requestWithRetry(async () => await client.post(url, formData, config));
176
176
  }
177
177
 
178
+ export async function postRaw(
179
+ url: string,
180
+ reqJar: any,
181
+ body: Buffer,
182
+ options?: any,
183
+ ctx?: any,
184
+ customHeader?: any,
185
+ ): Promise<any> {
186
+ const config: any = {
187
+ headers: getHeaders(url, options, ctx, customHeader),
188
+ timeout: 300000, // 5 min for large uploads
189
+ ...proxyConfig,
190
+ maxContentLength: Infinity,
191
+ maxBodyLength: Infinity,
192
+ validateStatus: (status: number) => status >= 200 && status < 600,
193
+ };
194
+ return requestWithRetry(async () => await client.post(url, body, config));
195
+ }
196
+
178
197
  export const getJar = (): CookieJar => jar;
@@ -46,6 +46,7 @@ function makeDefaults(html: string, userID: string | number, ctx: any): any {
46
46
  get: (url: string, jar: any, qs?: any, ctxx?: any, customHeader: any = {}) => network.get(url, jar, mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx, customHeader),
47
47
  post: (url: string, jar: any, form?: any, ctxx?: any, customHeader: any = {}) => network.post(url, jar, mergeWithDefaults(form), ctx.globalOptions, ctxx || ctx, customHeader),
48
48
  postFormData: (url: string, jar: any, form: any, qs?: any, ctxx?: any) => network.postFormData(url, jar, mergeWithDefaults(form), mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx),
49
+ postRaw: (url: string, jar: any, body: Buffer, ctxx?: any, customHeader: any = {}) => network.postRaw(url, jar, body, ctx.globalOptions, ctxx || ctx, customHeader),
49
50
  };
50
51
  }
51
52
 
package/LICENSE-MIT DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Avery, Benjamin, David, Maude
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,149 +0,0 @@
1
- /**
2
- * Example usage of post API functions
3
- * This demonstrates how to create, delete posts, upload photos, and get comments
4
- */
5
-
6
- const login = require('../module');
7
-
8
- // Your Facebook credentials
9
- const credentials = {
10
- appState: [] // Add your appState here
11
- };
12
-
13
- login(credentials, (err, api) => {
14
- if (err) {
15
- console.error('Login failed:', err);
16
- return;
17
- }
18
-
19
- console.log('Logged in successfully!');
20
-
21
- // Example 1: Create a post
22
- api.post.create({
23
- message: 'Hello from bb-fca!',
24
- privacy: 'SELF' // Options: 'EVERYONE', 'FRIENDS', 'SELF'
25
- }, (err, result) => {
26
- if (err) {
27
- console.error('Error creating post:', err);
28
- return;
29
- }
30
-
31
- console.log('Post created successfully!');
32
- console.log('Post ID:', result.postID);
33
- console.log('Success:', result.success);
34
- });
35
-
36
- // Example 2: Upload a photo
37
- api.post.uploadPhoto('./path/to/your/photo.png', (err, result) => {
38
- if (err) {
39
- console.error('Error uploading photo:', err);
40
- return;
41
- }
42
-
43
- console.log('Photo uploaded successfully!');
44
- console.log('Photo ID:', result.photoID);
45
- console.log('Upload ID:', result.uploadID);
46
- console.log('Success:', result.success);
47
- });
48
-
49
- // Example 3: Upload photo with Promise
50
- api.post.uploadPhoto('./path/to/your/photo.jpg')
51
- .then(result => {
52
- console.log('Photo uploaded:', result.photoID);
53
- })
54
- .catch(err => {
55
- console.error('Upload failed:', err);
56
- });
57
-
58
- // Example 3.1: Create a post with photo attachments
59
- // First upload the photo, then create post with photo ID
60
- api.post.uploadPhoto('./path/to/your/photo.png')
61
- .then(uploadResult => {
62
- return api.post.create({
63
- message: 'Check out this photo!',
64
- privacy: 'SELF',
65
- photos: [uploadResult.photoID] // Attach the uploaded photo
66
- });
67
- })
68
- .then(createResult => {
69
- console.log('Post with photo created successfully!');
70
- console.log('Post ID:', createResult.postID);
71
- })
72
- .catch(err => {
73
- console.error('Error:', err);
74
- });
75
-
76
- // Example 3.2: Create a post with multiple photos
77
- Promise.all([
78
- api.post.uploadPhoto('./photo1.jpg'),
79
- api.post.uploadPhoto('./photo2.jpg'),
80
- api.post.uploadPhoto('./photo3.jpg')
81
- ])
82
- .then(results => {
83
- const photoIDs = results.map(r => r.photoID);
84
- return api.post.create({
85
- message: 'Multiple photos!',
86
- privacy: 'FRIENDS',
87
- photos: photoIDs
88
- });
89
- })
90
- .then(result => {
91
- console.log('Post with multiple photos created!');
92
- console.log('Post ID:', result.postID);
93
- })
94
- .catch(err => {
95
- console.error('Error:', err);
96
- });
97
-
98
- // Example 4: Get comments from a post
99
- // URL: https://www.facebook.com/permalink.php?story_fbid=pfbid02WHHgPgDR9VuDfXiUR5KCseuh9f2NVmfwddGEgUuYKxrkJpFtqfUKbwcCBV7qAJxel&id=61588408996667
100
- api.post.getComments({
101
- story_fbid: 'pfbid02WHHgPgDR9VuDfXiUR5KCseuh9f2NVmfwddGEgUuYKxrkJpFtqfUKbwcCBV7qAJxel',
102
- id: '61588408996667'
103
- }, (err, comments) => {
104
- if (err) {
105
- console.error('Error getting comments:', err);
106
- return;
107
- }
108
-
109
- console.log(`Found ${comments.length} comments:`);
110
- comments.forEach((comment, index) => {
111
- console.log(`\n--- Comment ${index + 1} ---`);
112
- console.log(`ID: ${comment.id}`);
113
- console.log(`GraphQL ID: ${comment.graphql_id}`);
114
- console.log(`Text: ${comment.text}`);
115
- console.log(`Author: ${comment.author.name} (ID: ${comment.author.id})`);
116
- console.log(`Created: ${new Date(comment.created_time * 1000).toLocaleString('vi-VN')}`);
117
- console.log(`Replies: ${comment.reply_count}/${comment.total_reply_count}`);
118
- console.log(`Depth: ${comment.depth}`);
119
-
120
- if (comment.replies && comment.replies.length > 0) {
121
- console.log(` Nested replies:`);
122
- comment.replies.forEach((reply, i) => {
123
- console.log(` └─ [${i + 1}] ${reply.author.name}: ${reply.text}`);
124
- });
125
- }
126
- });
127
- });
128
-
129
- // Example 5: Get comments using just the story_fbid (will use current user's ID)
130
- api.post.getComments('pfbid02WHHgPgDR9VuDfXiUR5KCseuh9f2NVmfwddGEgUuYKxrkJpFtqfUKbwcCBV7qAJxel')
131
- .then(comments => {
132
- console.log(`\nUsing Promise: Found ${comments.length} comments`);
133
- })
134
- .catch(err => {
135
- console.error('Error:', err);
136
- });
137
-
138
- // Example 6: Delete a post
139
- api.post.delete('post_id_here', (err, result) => {
140
- if (err) {
141
- console.error('Error deleting post:', err);
142
- return;
143
- }
144
-
145
- console.log('Post deleted successfully!');
146
- console.log('Deleted Post ID:', result.postID);
147
- console.log('Success:', result.success);
148
- });
149
- });