Search code examples
facebookfacebook-graph-api

Get Facebook video id from fb.watch alias


Is there a way to get the video id from a fb.watch url that you get when you Copy Link on a video?

For example, this url : https://fb.watch/7zK5NDl3Dw/

has the video id 762932621316078 when you visit the link.

I would like to use the Video Graph Api, but it doesn't work with the alias /7zK5NDl3Dw. It does work with the id /762932621316078


Solution

  • fb.watch is just a link shortener, you can get a normal video URL by opening the fb.watch link with any HTTP client and checking the redirect URL. No API is needed.

    $ curl -i https://fb.watch/7zK5NDl3Dw/
    
    HTTP/2 302
    location: https://www.facebook.com/watch/?v=762932621316078&ref=sharing
    x-fb-rlafr: 0
    document-policy: force-load-at-top
    pragma: no-cache
    cache-control: private, no-cache, no-store, must-revalidate
    expires: Sat, 01 Jan 2000 00:00:00 GMT
    x-content-type-options: nosniff
    x-xss-protection: 0
    x-frame-options: DENY
    strict-transport-security: max-age=31536000; preload; includeSubDomains
    content-type: text/html; charset="utf-8"
    x-fb-debug: mIg31ie708sE6kGaRk7AVYWyELO5ZWqghkainJunir2RhsLeqCLYSqjDvF8mi6TQ6g2m50TQ/YRTPWW/u90BUg==
    content-length: 0
    date: Mon, 14 Mar 2022 16:15:51 GMT
    alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400