diff --git a/src/Embedly/Embedly.php b/src/Embedly/Embedly.php index 32021b1..425a67c 100644 --- a/src/Embedly/Embedly.php +++ b/src/Embedly/Embedly.php @@ -44,6 +44,12 @@ class Embedly { */ protected $user_agent = ""; + /** + * + * @var array + */ + protected $curl_opts = array(); + /** * * @var array|object @@ -60,7 +66,8 @@ public function __construct(array $args = array()) 'user_agent' => sprintf("Mozilla/5.0 (compatible; embedly-php/%s)", self::VERSION), 'key' => null, 'hostname' => null, - 'api_version' => null + 'api_version' => null, + 'curl_opts' => array() ), $args); if ($args['user_agent']) { @@ -75,6 +82,9 @@ public function __construct(array $args = array()) if ($args['api_version']) { $this->api_version = array_merge($this->api_version, $args['api_version']); } + if ($args['curl_opts']) { + $this->curl_opts = $args['curl_opts']; + } } /** @@ -338,12 +348,17 @@ protected function setCurlOptions(&$ch, $headers = array()) curl_setopt($ch, CURLOPT_BUFFERSIZE, 4096); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 25); curl_setopt($ch, CURLOPT_TIMEOUT, 30); + + // apply custom curl options specified in Embedly\Embedly constructor + foreach ($this->curl_opts as $option => $value) { + curl_setopt($ch, $option, $value); + } } /** * * @param resource $ch - * @return string + * @return array */ protected function curlExec(&$ch) { @@ -370,7 +385,7 @@ public static function reg_delim_stripper($r) /** * - * @param stdClass $o + * @param \stdClass $o * @return string */ public static function reg_imploder(\stdClass $o)