@@ -184,6 +184,95 @@ def clip_share_to_fb_config(self, device_status: Optional[Dict[str, object]] = N
184184 params = {"device_status" : json .dumps (device_status )},
185185 )
186186
187+ def clip_share_to_fb_extra_data (
188+ self ,
189+ config : Optional [Dict [str , object ]] = None ,
190+ destination_id : Optional [str ] = None ,
191+ destination_type : Optional [str ] = None ,
192+ destination_audience_type : Optional [str ] = None ,
193+ xpost_surface : str = "IG_REELS_COMPOSER" ,
194+ validation_check_bypass : Optional [bool ] = None ,
195+ ) -> Dict [str , object ]:
196+ """
197+ Build configure fields for sharing a Reel to Facebook.
198+
199+ Instagram Android 428 stores Reel Facebook cross-posting in
200+ ``XPlatformParams`` fields. The old ``share_to_facebook`` flag alone is
201+ not enough for accounts that require an explicit Facebook destination.
202+
203+ Parameters
204+ ----------
205+ config: Dict[str, object], optional
206+ Response from ``clip_share_to_fb_config()``. When omitted, this
207+ method fetches it.
208+ destination_id: str, optional
209+ Facebook destination id. Overrides config values.
210+ destination_type: str, optional
211+ Facebook destination type/posting type. Overrides config values.
212+ destination_audience_type: str, optional
213+ Facebook Reels audience type, e.g. ``PUBLIC``.
214+ xpost_surface: str, optional
215+ Cross-posting surface reported by the Instagram app.
216+ validation_check_bypass: bool, optional
217+ Whether to bypass app-side FB validation. Overrides config values.
218+
219+ Returns
220+ -------
221+ Dict
222+ Extra configure data for ``clip_upload(..., extra_data=...)``.
223+ """
224+ fb_config = (config if config is not None else self .clip_share_to_fb_config ()) or {}
225+ if fb_config .get ("share_to_fb_unavailable" ):
226+ raise ClientError ("Facebook Reel sharing is unavailable for this account" )
227+ if fb_config .get ("enabled" ) is False or fb_config .get ("is_account_linked" ) is False :
228+ raise ClientError ("Facebook Reel sharing is not enabled or no Facebook account is linked" )
229+
230+ destination_id = (
231+ destination_id
232+ or fb_config .get ("share_to_fb_destination_id" )
233+ or fb_config .get ("reels_destination_id" )
234+ or fb_config .get ("destination_id" )
235+ )
236+ destination_type = (
237+ destination_type
238+ or fb_config .get ("share_to_fb_destination_type" )
239+ or fb_config .get ("reels_cross_app_share_type" )
240+ or fb_config .get ("posting_type" )
241+ )
242+ destination_audience_type = (
243+ destination_audience_type
244+ or fb_config .get ("share_to_fb_destination_audience_type" )
245+ or fb_config .get ("reels_destination_audience_type" )
246+ or fb_config .get ("audience_type" )
247+ )
248+ if validation_check_bypass is None :
249+ validation_check_bypass = fb_config .get ("reels_cross_app_share_fb_validation_check_bypass" )
250+
251+ if not destination_id :
252+ raise ClientError (
253+ "Facebook Reel sharing configuration has no destination. "
254+ "Link a Facebook account/page in the Instagram app or pass destination_id."
255+ )
256+ if not destination_type :
257+ raise ClientError (
258+ "Facebook Reel sharing configuration has no destination type. "
259+ "Pass destination_type from a linked-account app capture."
260+ )
261+
262+ data = {
263+ "share_to_facebook" : "1" ,
264+ "is_reel_shared_to_fb" : True ,
265+ "share_to_facebook_reels" : True ,
266+ "share_to_fb_destination_id" : destination_id ,
267+ "share_to_fb_destination_type" : destination_type ,
268+ "xpost_surface" : xpost_surface ,
269+ }
270+ if destination_audience_type :
271+ data ["share_to_fb_destination_audience_type" ] = destination_audience_type
272+ if validation_check_bypass is not None :
273+ data ["cross_app_share_fb_validation_check_bypass" ] = bool (validation_check_bypass )
274+ return data
275+
187276 def clip_upload (
188277 self ,
189278 path : Path ,
@@ -196,6 +285,12 @@ def clip_upload(
196285 extra_data : Dict [str , object ] = {},
197286 trial : bool = False ,
198287 trial_graduation_strategy : str = "manual" ,
288+ share_to_facebook : bool = False ,
289+ fb_destination_id : Optional [str ] = None ,
290+ fb_destination_type : Optional [str ] = None ,
291+ fb_destination_audience_type : Optional [str ] = None ,
292+ fb_xpost_surface : str = "IG_REELS_COMPOSER" ,
293+ fb_validation_check_bypass : Optional [bool ] = None ,
199294 ) -> Media :
200295 """
201296 Upload CLIP to Instagram
@@ -220,11 +315,23 @@ def clip_upload(
220315 Forced to "0" for Trial Reels.
221316 extra_data: Dict[str, object], optional
222317 Dict of extra data, if you need to add your params,
223- like {"share_to_facebook ": 1}.
318+ like {"disable_comments ": 1}.
224319 trial: bool, optional
225320 Upload as a Trial Reel for eligible accounts, default is False.
226321 trial_graduation_strategy: str, optional
227322 Trial Reel graduation strategy, default is "manual".
323+ share_to_facebook: bool, optional
324+ Share this Reel to a linked Facebook account/page, default is False.
325+ fb_destination_id: str, optional
326+ Facebook destination id used when share_to_facebook is True.
327+ fb_destination_type: str, optional
328+ Facebook destination type used when share_to_facebook is True.
329+ fb_destination_audience_type: str, optional
330+ Facebook Reels audience type, e.g. ``PUBLIC``.
331+ fb_xpost_surface: str, optional
332+ Cross-posting surface reported by the Instagram app.
333+ fb_validation_check_bypass: bool, optional
334+ Override the validation bypass value from share_to_fb_config.
228335
229336 Returns
230337 -------
@@ -240,6 +347,15 @@ def clip_upload(
240347 clip_data = fp .read ()
241348 clip_len = str (len (clip_data ))
242349 configure_extra_data = dict (extra_data or {})
350+ if share_to_facebook :
351+ fb_extra_data = self .clip_share_to_fb_extra_data (
352+ destination_id = fb_destination_id ,
353+ destination_type = fb_destination_type ,
354+ destination_audience_type = fb_destination_audience_type ,
355+ xpost_surface = fb_xpost_surface ,
356+ validation_check_bypass = fb_validation_check_bypass ,
357+ )
358+ configure_extra_data = {** fb_extra_data , ** configure_extra_data }
243359 if trial :
244360 feed_show = "0"
245361 configure_extra_data .setdefault (
@@ -439,7 +555,7 @@ def clip_upload_as_reel_with_music(
439555 use cl.search_music(title)[0].dict()
440556
441557 extra_data: Dict[str, object], optional
442- Dict of extra data, if you need to add your params, like {"share_to_facebook ": 1}.
558+ Dict of extra data, if you need to add your params, like {"disable_comments ": 1}.
443559
444560 Returns
445561 -------
@@ -549,7 +665,7 @@ def clip_configure(
549665 location: Location, optional
550666 Location tag for this upload, default is None
551667 extra_data: Dict[str, object], optional
552- Dict of extra data, if you need to add your params, like {"share_to_facebook ": 1}.
668+ Dict of extra data, if you need to add your params, like {"disable_comments ": 1}.
553669
554670 Returns
555671 -------
0 commit comments