diff --git a/src/Kdyby/Facebook/Profile.php b/src/Kdyby/Facebook/Profile.php index d1eb2f53..904f188f 100644 --- a/src/Kdyby/Facebook/Profile.php +++ b/src/Kdyby/Facebook/Profile.php @@ -39,6 +39,37 @@ class Profile extends Nette\Object * @var ArrayHash */ private $details; + private $fields = [ + "address", + "name", + "age_range", + "birthday", + "about", + "gender", + "cover", + "devices", + "education", + "first_name", + "hometown", + "inspirational_people", + "interested_in", + "languages", + "last_name", + "link", + "locale", + "location", + "meeting_for", + "middle_name", + "name", + "name_format", + "profile_pic", + "relationship_status", + "religion", + "short_name", + "sports", + "website", + "work" + ]; @@ -69,27 +100,50 @@ public function getId() /** + * Get all details that you can with /me profile * @param string $key * @return ArrayHash|NULL */ - public function getDetails($key = NULL) + public function getDetails() { if ($this->details === NULL) { try { - $this->details = $this->facebook->api('/' . $this->profileId); + $this->details = $this->facebook->api('/' . $this->profileId,NULL,[ + "fields" => join(",",$this->fields) + ]); } catch (FacebookApiException $e) { $this->details = []; } } - if ($key !== NULL) { - return isset($this->details[$key]) ? $this->details[$key] : NULL; - } - return $this->details; } + /** + * @param array $keys + * @return ArrayHash|NULL + */ + public function getDetail($keys = ["name"]) + { + if ($this->details === NULL) { + try { + $this->details = $this->facebook->api('/' . $this->profileId,NULL,[ + "fields" => join(",",$keys) + ]); + + } catch (FacebookApiException $e) { + $this->details = []; + } + } + + if ($key !== NULL) { + return isset($this->details[$key]) ? $this->details[$key] : NULL; + } + + return $this->details; + } + /**