|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Bambuser.php |
|
4
|
|
|
* |
|
5
|
|
|
* @package Providers |
|
6
|
|
|
* @author Michael Pratt <[email protected]> |
|
7
|
|
|
* @link http://www.michael-pratt.com/ |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Embera\Providers; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* The bambuser.com Provider |
|
17
|
|
|
* @link http://bambuser.com |
|
18
|
|
|
* @link http://bambuser.com/api/embed_oembed |
|
19
|
|
|
*/ |
|
20
|
|
|
class Bambuser extends \Embera\Adapters\Service |
|
21
|
|
|
{ |
|
22
|
|
|
/** inline {@inheritdoc} */ |
|
23
|
|
|
protected $apiUrl = 'http://api.bambuser.com/oembed.json'; |
|
24
|
|
|
|
|
25
|
|
|
/** inline {@inheritdoc} */ |
|
26
|
2 |
|
protected function validateUrl() |
|
27
|
|
|
{ |
|
28
|
2 |
|
$this->url->stripLastSlash(); |
|
29
|
2 |
|
$this->url->stripWWW(); |
|
30
|
|
|
|
|
31
|
|
|
return ( |
|
32
|
2 |
|
preg_match('~bambuser\.com/v/(?:[0-9]+)$~i', $this->url) || preg_match('~bambuser\.com/channel/(?:[^/]+)$~i', $this->url) |
|
33
|
2 |
|
); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** inline {@inheritdoc} */ |
|
37
|
2 |
|
public function normalizeUrl() |
|
38
|
|
|
{ |
|
39
|
2 |
|
if (preg_match('~bambuser\.com/channel/(?:[^/]+)/broadcast/([0-9]+)~i', $this->url, $matches)) { |
|
40
|
2 |
|
$this->url = new \Embera\Url('http://bambuser.com/v/' . $matches['1']); |
|
41
|
2 |
|
} |
|
42
|
2 |
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** inline {@inheritdoc} */ |
|
45
|
2 |
|
public function fakeResponse() |
|
46
|
|
|
{ |
|
47
|
|
|
$defaults = array( |
|
48
|
2 |
|
'type' => 'video', |
|
49
|
2 |
|
'provider_name' => 'Bambuser.com', |
|
50
|
2 |
|
'provider_url' => 'http://bambuser.com', |
|
51
|
2 |
|
); |
|
52
|
|
|
|
|
53
|
2 |
|
$html = '<object id="bplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}">'; |
|
54
|
2 |
|
$html .= '<embed allowfullscreen="true" allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" name="bplayer" src="https://static.bambuser.com/r/player.swf?{query}&context=oembed" width="{width}" height="{height}" />'; |
|
55
|
2 |
|
$html .= '<param name="movie" value="https://static.bambuser.com/r/player.swf?context=oembed&{query}" />'; |
|
56
|
2 |
|
$html .= '<param name="allowfullscreen" value="true" />'; |
|
57
|
2 |
|
$html .= '<param name="allowscriptaccess" value="always" />'; |
|
58
|
2 |
|
$html .= '<param name="wmode" value="transparent" />'; |
|
59
|
2 |
|
$html .= '</object>'; |
|
60
|
|
|
|
|
61
|
2 |
|
if (preg_match('~/v/([0-9]+)$~i', $this->url, $matches)) { |
|
62
|
2 |
|
return array_merge( |
|
63
|
2 |
|
$defaults, |
|
64
|
2 |
|
array('html' => str_replace('{query}', 'vid=' . $matches['1'], $html)) |
|
65
|
2 |
|
); |
|
66
|
|
|
} |
|
67
|
|
|
else if (preg_match('~/channel/([^/]+)~i', $this->url, $matches)) |
|
68
|
|
|
{ |
|
69
|
|
|
return array_merge( |
|
70
|
|
|
$defaults, |
|
71
|
|
|
array('html' => str_replace('{query}', 'username=' . urlencode($matches['1']), $html)) |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return array(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
?> |
|
|
|
|
|
|
81
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.