Commit 29d0dd740c329c2674de58bec172419148a1b495
- Diff rendering mode:
- inline
- side by side
extlib/Services/oEmbed.php
(4 / 4)
|   | |||
| 256 | 256 | ||
| 257 | 257 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| 258 | 258 | if (substr($code, 0, 1) != '2') { | |
| 259 | throw new Services_oEmbed_Exception('Non-200 code returned'); | ||
| 259 | throw new Services_oEmbed_Exception('Non-200 code returned. Got code ' . $code); | ||
| 260 | 260 | } | |
| 261 | 261 | ||
| 262 | 262 | curl_close($ch); | |
| … | … | ||
| 302 | 302 | ||
| 303 | 303 | // Find all <link /> tags that have a valid oembed type set. We then | |
| 304 | 304 | // extract the href attribute for each type. | |
| 305 | $regexp = '#<link([^>]*)type="' . | ||
| 305 | $regexp = '#<link([^>]*)type[\s\n]*=[\s\n]*"' . | ||
| 306 | 306 | '(application/json|text/xml)\+oembed"([^>]*)>#im'; | |
| 307 | 307 | ||
| 308 | 308 | $m = $ret = array(); | |
| … | … | ||
| 314 | 314 | ||
| 315 | 315 | foreach ($m[0] as $i => $link) { | |
| 316 | 316 | $h = array(); | |
| 317 | if (preg_match('/href="([^"]+)"/i', $link, $h)) { | ||
| 317 | if (preg_match('/[\s\n]+href[\s\n]*=[\s\n]*"([^"]+)"/im', $link, $h)) { | ||
| 318 | 318 | $ret[$m[2][$i]] = $h[1]; | |
| 319 | 319 | } | |
| 320 | 320 | } | |
| … | … | ||
| 347 | 347 | ||
| 348 | 348 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| 349 | 349 | if (substr($code, 0, 1) != '2') { | |
| 350 | throw new Services_oEmbed_Exception('Non-200 code returned'); | ||
| 350 | throw new Services_oEmbed_Exception('Non-200 code returned. Got code ' . $code); | ||
| 351 | 351 | } | |
| 352 | 352 | ||
| 353 | 353 | return $result; |
Comments
Add a new comment:
Login or create an account to post a comment
Add your comment
Please log in to comment

