bb-fca 2.0.6 → 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.
@@ -374,6 +374,56 @@ export interface ThreadInfo {
374
374
  };
375
375
  }
376
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
+
377
427
  export interface MessageObject {
378
428
  body?: string;
379
429
  attachment?: ReadStream[];
@@ -852,6 +902,9 @@ export interface API {
852
902
  /** Add an external module to extend the API. */
853
903
  addExternalModule(moduleObj: Record<string, Function>): void;
854
904
 
905
+ /** Group-related API methods. */
906
+ group: GroupModule;
907
+
855
908
  /** Allow accessing dynamically loaded methods. */
856
909
  [key: string]: any;
857
910
  }
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,189 +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 7: Upload a video
139
- api.post.uploadVideo('./path/to/your/video.mp4', (err, result) => {
140
- if (err) {
141
- console.error('Error uploading video:', err);
142
- return;
143
- }
144
-
145
- console.log('Video uploaded successfully!');
146
- console.log('Video ID:', result.videoID);
147
- console.log('Upload ID:', result.uploadID);
148
- console.log('Upload Session ID:', result.uploadSessionID);
149
- console.log('Success:', result.success);
150
- });
151
-
152
- // Example 8: Upload video with Promise
153
- api.post.uploadVideo('./path/to/your/video.mp4')
154
- .then(result => {
155
- console.log('Video uploaded:', result.videoID);
156
- })
157
- .catch(err => {
158
- console.error('Video upload failed:', err);
159
- });
160
-
161
- // Example 9: Create a post with a video attachment
162
- api.post.uploadVideo('./path/to/your/video.mp4')
163
- .then(uploadResult => {
164
- return api.post.create({
165
- message: 'Check out this video!',
166
- privacy: 'SELF',
167
- videos: [uploadResult.videoID]
168
- });
169
- })
170
- .then(createResult => {
171
- console.log('Post with video created successfully!');
172
- console.log('Post ID:', createResult.postID);
173
- })
174
- .catch(err => {
175
- console.error('Error:', err);
176
- });
177
-
178
- // Example 10: Delete a post
179
- api.post.delete('post_id_here', (err, result) => {
180
- if (err) {
181
- console.error('Error deleting post:', err);
182
- return;
183
- }
184
-
185
- console.log('Post deleted successfully!');
186
- console.log('Deleted Post ID:', result.postID);
187
- console.log('Success:', result.success);
188
- });
189
- });