Skip to content

Commit

Permalink
Add support for custom CURL options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andjelko Horvat committed Apr 4, 2012
1 parent aba1cc4 commit f4f9b36
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/base_facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ abstract class BaseFacebook
*/
protected $fileUploadSupport = false;

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

/**
* Initialize a Facebook Application.
*
Expand Down Expand Up @@ -853,7 +860,7 @@ protected function makeRequest($url, $params, $ch=null) {
$ch = curl_init();
}

$opts = self::$CURL_OPTS;
$opts = $this->getCurlOptions();
if ($this->getFileUploadSupport()) {
$opts[CURLOPT_POSTFIELDS] = $params;
} else {
Expand Down Expand Up @@ -1221,6 +1228,26 @@ protected function getMetadataCookie() {
return $metadata;
}

/**
* Set custom CURL options.
*
* @param array $curlOptions CURL options
* @return BaseFacebook
*/
public function setCurlOptions(array $curlOptions) {
$this->curl_opts = $curlOptions;
return $this;
}

/**
* Get CURL options (default + custom).
*
* @return array CURL options
*/
public function getCurlOptions() {
return $this->curl_opts + self::$CURL_OPTS;
}

/**
* Each of the following four methods should be overridden in
* a concrete subclass, as they are in the provided Facebook class.
Expand Down

0 comments on commit f4f9b36

Please sign in to comment.