@@ -18,6 +18,12 @@ export async function getMyUid() {
1818
1919export async function fetchGraphQl ( params , url ) {
2020 let query = "" ;
21+ const fb_dtsg = await getFbDtsg ( ) ;
22+ if ( ! fb_dtsg ) {
23+ console . error ( "fb_dtsg not found" ) ;
24+ return null ;
25+ }
26+
2127 if ( typeof params === "string" ) query = "&q=" + encodeURIComponent ( params ) ;
2228 else
2329 query = wrapGraphQlParams ( {
@@ -30,7 +36,7 @@ export async function fetchGraphQl(params, url) {
3036 } ) ;
3137
3238 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 ,
3440 method : "POST" ,
3541 headers : { "Content-Type" : "application/x-www-form-urlencoded" } ,
3642 credentials : "include" ,
@@ -88,7 +94,7 @@ export async function getFbDtsg() {
8894 Accept : "text/html" ,
8995 } ,
9096 } ) ;
91- text = res . text ( ) ;
97+ text = await res . text ( ) ;
9298 dtsg =
9399 RegExp ( / " d t s g " : { " t o k e n " : " ( [ ^ " ] + ) " / ) . exec ( text ) ?. [ 1 ] ||
94100 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) {
113119}
114120
115121export 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+ }
122133}
123134
124135export async function getPostIdFromUrl ( url , checkRedirected = true ) {
@@ -326,7 +337,7 @@ export async function sharePostToGroup({
326337 link : {
327338 share_scrape_data : JSON . stringify ( {
328339 share_type : postOwner . type === TargetType . Group ? 37 : 22 ,
329- share_params : [ postId ] ,
340+ share_params : [ parseInt ( postId ) ] ,
330341 } ) ,
331342 } ,
332343 } ,
@@ -364,15 +375,19 @@ export async function sharePostToGroup({
364375 hashtag : null ,
365376 canUserManageOffers : false ,
366377 __relay_internal__pv__CometUFIShareActionMigrationrelayprovider : true ,
378+ __relay_internal__pv__GHLShouldChangeSponsoredDataFieldNamerelayprovider : true ,
379+ __relay_internal__pv__GHLShouldChangeAdIdFieldNamerelayprovider : false ,
367380 __relay_internal__pv__IncludeCommentWithAttachmentrelayprovider : true ,
368381 __relay_internal__pv__CometUFIReactionsEnableShortNamerelayprovider : false ,
369382 __relay_internal__pv__CometImmersivePhotoCanUserDisable3DMotionrelayprovider : false ,
370383 __relay_internal__pv__IsWorkUserrelayprovider : false ,
371384 __relay_internal__pv__IsMergQAPollsrelayprovider : false ,
385+ __relay_internal__pv__FBReelsMediaFooter_comet_enable_reels_ads_gkrelayprovider : false ,
372386 __relay_internal__pv__StoriesArmadilloReplyEnabledrelayprovider : true ,
373387 __relay_internal__pv__EventCometCardImage_prefetchEventImagerelayprovider : false ,
388+ __relay_internal__pv__GHLShouldChangeSponsoredAuctionDistanceFieldNamerelayprovider : false ,
374389 } ,
375- doc_id : "8288041211276925 " ,
390+ doc_id : "8530376237028021 " ,
376391 } ) ;
377392 const json = JSON . parse ( res ?. split ?. ( "\n" ) ?. [ 0 ] ) ;
378393 console . log ( json ) ;
0 commit comments