https://www.facebook.com/photo.php?v=[ID]
https://www.facebook.com/photo.php?v=[ID]&type=2&theater
$url = 'https://www.facebook.com/photo.php?v=[ID]&type=2&theater';
parse_str( parse_url( $url, PHP_URL_QUERY ), $params );
// $params['v'] will hold the [ID] you need.