diff options
author | Luke Bratch <luke@bratch.co.uk> | 2015-09-30 11:00:41 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2015-09-30 11:00:41 +0100 |
commit | 8fb2d7b5c69e38bea780c758e15185bba0cef4f9 (patch) | |
tree | 94431d1a8a03b10dc408dd8240d2196e5843f4f4 /iplayer.php | |
parent | 5a36c3d531e6dbdf9d1cb45d44ef99a6cbfd5796 (diff) |
Switch to using cURL instead of get_file_contents to allow bind address
to be specified
Diffstat (limited to 'iplayer.php')
-rw-r--r-- | iplayer.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/iplayer.php b/iplayer.php index b1a2007..e97cc2a 100644 --- a/iplayer.php +++ b/iplayer.php @@ -1,4 +1,6 @@ <?php +define("CURLIFACE", "192.168.122.9"); + // Grab the programme ID with GET, or with POST, or present a URL form if (isset($_GET['id'])) { $id = $_GET['id']; @@ -29,7 +31,13 @@ $vpidlen = strpos($html, '"', $vpidpos) - $vpidpos; $vpid = substr($html, $vpidpos, $vpidlen); // Grab the JSON which appears to be within some JavaScript -$notjson = file_get_contents("http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/vpid/$vpid/format/json/mediaset/apple-ipad-hls/jsfunc/JS_callbacks39"); +$curl = curl_init(); +curl_setopt($curl, CURLOPT_INTERFACE, CURLIFACE); +curl_setopt($curl, CURLOPT_URL, "http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/vpid/$vpid/format/json/mediaset/apple-ipad-hls/jsfunc/JS_callbacks39"); +curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); +curl_setopt($curl, CURLOPT_HEADER, false); +$notjson = curl_exec($curl); +curl_close($curl); // Extract the actual JSON inside the JavaScript $jsonpos = strpos($notjson, '{'); |