Permalink
Browse files

added public static variable for default curl options

  • Loading branch information...
daaku committed Apr 24, 2010
1 parent 0788870 commit 0b3776f7ce5e131b6f24930b066f2db7d4f92959
Showing with 15 additions and 13 deletions.
  1. +15 −13 facebook.php
View
@@ -76,18 +76,23 @@ public function __toString() {
*/
class Facebook
{
- /**
- * The User-Agent when making API calls.
- */
- const USER_AGENT = 'facebook-php-2.0';
-
/**
* List of error codes that trigger clearing of the session.
*/
private static $SESSION_INVALID_ERRORS = array(
190, // Invalid OAuth Access Token
);
+ /**
+ * Default options for curl.
+ */
+ public static $CURL_OPTS = array(
+ CURLOPT_CONNECTTIMEOUT => 10,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_TIMEOUT => 60,
+ CURLOPT_USERAGENT => 'facebook-php-2.0',
+ );
+
/**
* List of query parameters that get automatically dropped when rebuilding
* the current URL.
@@ -491,14 +496,11 @@ protected function makeRequest($url, $params, $ch=null) {
if (!$ch) {
$ch = curl_init();
}
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_POSTFIELDS => http_build_query($params, null, '&'),
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_USERAGENT => self::USER_AGENT,
- CURLOPT_CONNECTTIMEOUT => 10,
- CURLOPT_TIMEOUT => 60,
- ));
+
+ $opts = self::$CURL_OPTS;
+ $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
+ $opts[CURLOPT_URL] = $url;
+ curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
curl_close($ch);
return $result;

0 comments on commit 0b3776f

Please sign in to comment.