Created
November 8, 2018 01:17
-
-
Save rxnlabs/e6dac28b434cce568bea75578282cd27 to your computer and use it in GitHub Desktop.
PHP - Detect if a link text contains Facebook embeddable content using regular Expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Detect if the content contains any Facebook links that can be embedded based on this doc | |
// https://developers.facebook.com/docs/plugins/oembed-endpoints/ | |
$content = 'https://www.facebook.com/facebook/videos/10153231379946729/'; | |
preg_match_all( '/http(s):\/\/(www.)facebook.com\/((?<=\/).+(?<=\/)posts|(?<=\/).+(?<=\/)activity|photo(s|\.php)|permalink\.php|media|questions|notes|(?<=\/).+(?<=\/)videos|video\.php)/', $content, $matches ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment