From 429a462ee0dcb1342f182402d35ca4779f5d4f58 Mon Sep 17 00:00:00 2001 From: Lienhart Woitok Date: Tue, 15 Jul 2014 13:50:43 +0200 Subject: [PATCH] Add option to use HTTP proxy for requests --- README.md | 4 ++++ bc-mapi.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 647091b..b3a6652 100644 --- a/README.md +++ b/README.md @@ -410,6 +410,10 @@ The constructor for the BCMAPI class. Type: Integer +- **proxy** *Public - HTTP Proxy to use for connecting to Brightcove services.* + + Type: String + - **secure** *Private - Whether BCMAPI is operating over HTTPS* Type: Boolean diff --git a/bc-mapi.php b/bc-mapi.php index d68817b..337d3b9 100644 --- a/bc-mapi.php +++ b/bc-mapi.php @@ -65,6 +65,7 @@ class BCMAPI private $api_calls = 0; private $bit32 = FALSE; private $media_delivery = 'default'; + private $proxy = NULL; private $secure = FALSE; private $show_notices = FALSE; private $timeout_attempts = 100; @@ -1358,6 +1359,10 @@ private function curlRequest($request, $get_request = FALSE) curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $request); } + if(!is_null($this->proxy)) + { + curl_setopt($curl, CURLOPT_PROXY, $this->proxy); + } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl);