Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/Embedly/Embedly.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class Embedly {
*/
protected $user_agent = "";

/**
*
* @var array
*/
protected $curl_opts = array();

/**
*
* @var array|object
Expand All @@ -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']) {
Expand All @@ -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'];
}
}

/**
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down