diff --git a/mythtv/bindings/php/MythBackend.php b/mythtv/bindings/php/MythBackend.php
index 16781e8..8446984 100644
a
|
b
|
class MythBackend { |
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
| 215 | |
| 216 | /** |
| 217 | * Request something from the backend's HTTP API and return it |
| 218 | * as JSON. This is just syntactic sugar for httpRequest |
| 219 | /**/ |
| 220 | public function httpRequestAsJson($path, $args = array(), $opts = null) { |
| 221 | if (!$opts) { |
| 222 | $opts = array(); |
| 223 | } |
| 224 | |
| 225 | if (!$opts['http']) { |
| 226 | $opts['http'] = array(); |
| 227 | } |
| 228 | |
| 229 | if (!$opts['http']['method']) { |
| 230 | $opts['http']['method'] = "GET"; |
| 231 | } |
| 232 | |
| 233 | $opts['http']['header'] = "Accept: application/json\r\n"; |
| 234 | |
| 235 | return $this->httpRequest($path, $args, $opts); |
| 236 | } |
| 237 | |
215 | 238 | /** |
216 | 239 | * Request something from the backend's HTTP API |
217 | 240 | /**/ |
218 | | public function httpRequest($path, $args = array()) { |
| 241 | public function httpRequest($path, $args = array(), $opts = null) { |
219 | 242 | $url = "http://{$this->ip}:{$this->port_http}/{$path}?"; |
220 | 243 | foreach ($args as $key => $value) { |
221 | 244 | $url .= urlencode($key).'='.urlencode($value).'&'; |
222 | 245 | } |
223 | | return @file_get_contents($url); |
| 246 | |
| 247 | if (!$opts) { |
| 248 | return @file_get_contents($url); |
| 249 | } else { |
| 250 | $context = stream_context_create($opts); |
| 251 | return @file_get_contents($url, false, $context); |
| 252 | } |
224 | 253 | } |
225 | 254 | |
226 | 255 | } |