@@ -18,6 +18,12 @@ export async function getMyUid() {
18
18
19
19
export async function fetchGraphQl ( params , url ) {
20
20
let query = "" ;
21
+ const fb_dtsg = await getFbDtsg ( ) ;
22
+ if ( ! fb_dtsg ) {
23
+ console . error ( "fb_dtsg not found" ) ;
24
+ return null ;
25
+ }
26
+
21
27
if ( typeof params === "string" ) query = "&q=" + encodeURIComponent ( params ) ;
22
28
else
23
29
query = wrapGraphQlParams ( {
@@ -30,7 +36,7 @@ export async function fetchGraphQl(params, url) {
30
36
} ) ;
31
37
32
38
const res = await fetch ( url || "https://www.facebook.com/api/graphql/" , {
33
- body : query + "&fb_dtsg=" + ( await getFbDtsg ( ) ) ,
39
+ body : query + "&fb_dtsg=" + fb_dtsg ,
34
40
method : "POST" ,
35
41
headers : { "Content-Type" : "application/x-www-form-urlencoded" } ,
36
42
credentials : "include" ,
@@ -88,7 +94,7 @@ export async function getFbDtsg() {
88
94
Accept : "text/html" ,
89
95
} ,
90
96
} ) ;
91
- text = res . text ( ) ;
97
+ text = await res . text ( ) ;
92
98
dtsg =
93
99
RegExp ( / " d t s g " : { " t o k e n " : " ( [ ^ " ] + ) " / ) . exec ( text ) ?. [ 1 ] ||
94
100
RegExp ( / " n a m e " : " f b _ d t s g " , " v a l u e " : " ( [ ^ " ] + ) / ) . exec ( text ) ?. [ 1 ] ;
@@ -113,12 +119,17 @@ export function findDataObject(object) {
113
119
}
114
120
115
121
export async function convertStoryIdToPostId ( storyId ) {
116
- const res = await fetchGraphQl ( {
117
- q : `node(${ storyId } ){id}` ,
118
- } ) ;
119
- // {"2616483865189864":null}
120
- const json = JSON . parse ( res ) ;
121
- return Object . keys ( json ) ?. [ 0 ] ;
122
+ try {
123
+ const res = await fetchGraphQl ( {
124
+ q : `node(${ storyId } ){id}` ,
125
+ } ) ;
126
+ // {"2616483865189864":null}
127
+ const json = JSON . parse ( res ) ;
128
+ return Object . keys ( json ) ?. [ 0 ] ;
129
+ } catch ( e ) {
130
+ console . log ( e ) ;
131
+ return null ;
132
+ }
122
133
}
123
134
124
135
export async function getPostIdFromUrl ( url , checkRedirected = true ) {
@@ -326,7 +337,7 @@ export async function sharePostToGroup({
326
337
link : {
327
338
share_scrape_data : JSON . stringify ( {
328
339
share_type : postOwner . type === TargetType . Group ? 37 : 22 ,
329
- share_params : [ postId ] ,
340
+ share_params : [ parseInt ( postId ) ] ,
330
341
} ) ,
331
342
} ,
332
343
} ,
@@ -364,15 +375,19 @@ export async function sharePostToGroup({
364
375
hashtag : null ,
365
376
canUserManageOffers : false ,
366
377
__relay_internal__pv__CometUFIShareActionMigrationrelayprovider : true ,
378
+ __relay_internal__pv__GHLShouldChangeSponsoredDataFieldNamerelayprovider : true ,
379
+ __relay_internal__pv__GHLShouldChangeAdIdFieldNamerelayprovider : false ,
367
380
__relay_internal__pv__IncludeCommentWithAttachmentrelayprovider : true ,
368
381
__relay_internal__pv__CometUFIReactionsEnableShortNamerelayprovider : false ,
369
382
__relay_internal__pv__CometImmersivePhotoCanUserDisable3DMotionrelayprovider : false ,
370
383
__relay_internal__pv__IsWorkUserrelayprovider : false ,
371
384
__relay_internal__pv__IsMergQAPollsrelayprovider : false ,
385
+ __relay_internal__pv__FBReelsMediaFooter_comet_enable_reels_ads_gkrelayprovider : false ,
372
386
__relay_internal__pv__StoriesArmadilloReplyEnabledrelayprovider : true ,
373
387
__relay_internal__pv__EventCometCardImage_prefetchEventImagerelayprovider : false ,
388
+ __relay_internal__pv__GHLShouldChangeSponsoredAuctionDistanceFieldNamerelayprovider : false ,
374
389
} ,
375
- doc_id : "8288041211276925 " ,
390
+ doc_id : "8530376237028021 " ,
376
391
} ) ;
377
392
const json = JSON . parse ( res ?. split ?. ( "\n" ) ?. [ 0 ] ) ;
378
393
console . log ( json ) ;
0 commit comments