Skip to content

Commit

Permalink
Fix getMetadataCookie()
Browse files Browse the repository at this point in the history
Fix the Fatal error: Call to undefined method Facebook::getMetadataCookie()
  • Loading branch information
agusesetiyono committed Dec 9, 2012
1 parent c7fe993 commit b1fd927
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion application/modules/account/helpers/facebook_helper.php
Expand Up @@ -1212,6 +1212,38 @@ protected function getCurrentUrl() {
// rebuild // rebuild
return $protocol . $parts['host'] . $port . $parts['path'] . $query; 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 * Returns true if and only if the key or key/value pair should
Expand Down Expand Up @@ -1437,4 +1469,4 @@ protected function constructSessionVariableName($key) {
} }
return implode('_', $parts); return implode('_', $parts);
} }
} }

0 comments on commit b1fd927

Please sign in to comment.