* @file include/oembed.php
*/
-use \Friendica\ParseUrl;
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\ParseUrl;
+use Friendica\Core\Config;
function oembed_replacecb($matches){
$embedurl=$matches[1];
/**
* @brief Get data from an URL to embed its content.
- *
+ *
* @param string $embedurl The URL from which the data should be fetched.
* @param bool $no_rich_type If set to true rich type content won't be fetched.
- *
+ *
* @return bool|object Returns object with embed content or false if no embedable
* content exists
*/
// These media files should now be caught in bbcode.php
// left here as a fallback in case this is called from another source
- $noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm");
- $ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION);
+ $noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
+ $ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
if (is_null($txt)) {
}
}
- if ($txt==false || $txt=="") {
- $embedly = Config::get("system", "embedly");
- if ($embedly != "") {
- // try embedly service
- $ourl = "https://api.embed.ly/1/oembed?key=".$embedly."&url=".urlencode($embedurl);
- $txt = fetch_url($ourl);
-
- logger("oembed_fetch_url: ".$txt, LOGGER_DEBUG);
- }
- }
-
- $txt=trim($txt);
+ $txt = trim($txt);
- if ($txt[0]!="{") {
- $txt='{"type":"error"}';
+ if ($txt[0] != "{") {
+ $txt = '{"type":"error"}';
} else { //save in cache
$j = json_decode($txt);
if ($j->type != "error") {
$j->embedurl = $embedurl;
// If fetching information doesn't work, then improve via internal functions
- if (($j->type == "error") OR ($no_rich_type AND ($j->type == "rich"))) {
+ if (($j->type == "error") || ($no_rich_type && ($j->type == "rich"))) {
$data = ParseUrl::getSiteinfoCached($embedurl, true, false);
$j->type = $data["type"];
if (isset($j->author_name)) {
$ret.=" (".$j->author_name.")";
}
- } elseif (isset($j->provider_name) OR isset($j->author_name)) {
+ } elseif (isset($j->provider_name) || isset($j->author_name)) {
$embedlink = "";
if (isset($j->provider_name)) {
$embedlink .= $j->provider_name;