Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix getMetadataCookie()

Fix the Fatal error: Call to undefined method Facebook::getMetadataCookie()
  • Loading branch information...
commit b1fd92714d628342ee04f5db201c2d538d35201a 1 parent c7fe993
@agusesetiyono agusesetiyono authored
Showing with 33 additions and 1 deletion.
  1. +33 −1 application/modules/account/helpers/facebook_helper.php
View
34 application/modules/account/helpers/facebook_helper.php
@@ -1212,6 +1212,38 @@ protected function getCurrentUrl() {
// rebuild
return $protocol . $parts['host'] . $port . $parts['path'] . $query;
}
+
+ /**
+ * Parses the metadata cookie that our Javascript API set
+ *
+ * @return an array mapping key to value
+ */
+ protected function getMetadataCookie() {
+ $cookie_name = $this->getMetadataCookieName();
+ if (!array_key_exists($cookie_name, $_COOKIE)) {
+ return array();
+ }
+
+ // The cookie value can be wrapped in "-characters so remove them
+ $cookie_value = trim($_COOKIE[$cookie_name], '"');
+
+ if (empty($cookie_value)) {
+ return array();
+ }
+
+ $parts = explode('&', $cookie_value);
+ $metadata = array();
+ foreach ($parts as $part) {
+ $pair = explode('=', $part, 2);
+ if (!empty($pair[0])) {
+ $metadata[urldecode($pair[0])] =
+ (count($pair) > 1) ? urldecode($pair[1]) : '';
+ }
+ }
+
+ return $metadata;
+ }
+
/**
* Returns true if and only if the key or key/value pair should
@@ -1437,4 +1469,4 @@ protected function constructSessionVariableName($key) {
}
return implode('_', $parts);
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.