X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=extlib%2FServices%2FoEmbed.php;h=0dc8f01b2f4580ba3734ec133370ec58cca33628;hb=38409f1683351ae2b9bc932d441c6021a8b2aae7;hp=5d38ed883d50fb6e5e5333691032f9d53cea55ca;hpb=b3a0eea3b66e95becb6c4595ed71c7fe71ed6437;p=quix0rs-gnu-social.git
diff --git a/extlib/Services/oEmbed.php b/extlib/Services/oEmbed.php
index 5d38ed883d..0dc8f01b2f 100644
--- a/extlib/Services/oEmbed.php
+++ b/extlib/Services/oEmbed.php
@@ -162,7 +162,7 @@ class Services_oEmbed
}
if ($this->options[self::OPTION_API] === null) {
- $this->options[self::OPTION_API] = $this->discover();
+ $this->options[self::OPTION_API] = $this->discover($url);
}
}
@@ -256,7 +256,7 @@ class Services_oEmbed
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (substr($code, 0, 1) != '2') {
- throw new Services_oEmbed_Exception('Non-200 code returned');
+ throw new Services_oEmbed_Exception('Non-200 code returned. Got code ' . $code);
}
curl_close($ch);
@@ -302,8 +302,8 @@ class Services_oEmbed
// Find all tags that have a valid oembed type set. We then
// extract the href attribute for each type.
- $regexp = '#]*)type="' .
- '(application/json|text/xml)\+oembed"([^>]*)>#i';
+ $regexp = '#]*)type[\s\n]*=[\s\n]*"' .
+ '(application/json|text/xml)\+oembed"([^>]*)>#im';
$m = $ret = array();
if (!preg_match_all($regexp, $body, $m)) {
@@ -314,12 +314,12 @@ class Services_oEmbed
foreach ($m[0] as $i => $link) {
$h = array();
- if (preg_match('/href="([^"]+)"/i', $link, $h)) {
+ if (preg_match('/[\s\n]+href[\s\n]*=[\s\n]*"([^"]+)"/im', $link, $h)) {
$ret[$m[2][$i]] = $h[1];
}
}
- return (isset($ret['json']) ? $ret['json'] : array_pop($ret));
+ return (isset($ret['application/json']) ? $ret['application/json'] : array_pop($ret));
}
/**
@@ -347,7 +347,7 @@ class Services_oEmbed
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (substr($code, 0, 1) != '2') {
- throw new Services_oEmbed_Exception('Non-200 code returned');
+ throw new Services_oEmbed_Exception('Non-200 code returned. Got code ' . $code);
}
return $result;