Permalink
Browse files

Add support for custom CURL options.

  • Loading branch information...
1 parent aba1cc4 commit f4f9b363e8bbc448ed8f71cd3bd5b6ed7640bd28 @comel committed Apr 4, 2012
Showing with 28 additions and 1 deletion.
  1. +28 −1 src/base_facebook.php
View
@@ -201,6 +201,13 @@ public function __toString() {
protected $fileUploadSupport = false;
/**
+ * Custom CURL options
+ *
+ * @var array
+ */
+ protected $curl_opts = array();
+
+ /**
* Initialize a Facebook Application.
*
* The configuration:
@@ -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 {
@@ -1222,6 +1229,26 @@ protected function getMetadataCookie() {
}
/**
+ * 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.
* The Facebook class uses PHP sessions to provide a primitive

0 comments on commit f4f9b36

Please sign in to comment.