From bc5d86195c0a12b00d77ea7b70e564279fcd1bc5 Mon Sep 17 00:00:00 2001 From: VyseExhale Date: Fri, 9 May 2014 15:18:30 +0200 Subject: [PATCH] :D --- bdFacebookGraph.php | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 bdFacebookGraph.php diff --git a/bdFacebookGraph.php b/bdFacebookGraph.php new file mode 100644 index 0000000..07e4ddb --- /dev/null +++ b/bdFacebookGraph.php @@ -0,0 +1,63 @@ +APP_ID = $getAppID; + $this->APP_SECRET = $getAppSecret; + //set the facebook session + $this->setSession(); + } + + private function setSession() + { + $strAccesToken = $this->APP_ID.'|'.$this->APP_SECRET; + $this->FacebookSession = new FacebookSession($strAccesToken); + if (! $this->FacebookSession) + throw new Exception("Can not set Facebook Session with access token $strAccesToken", 1); + } + + public function fetchByRequest($getStrGraphRequest = false) + { + if (! $getStrGraphRequest) return ; + try { + $arrFBrequest = (new FacebookRequest( + $this->FacebookSession, + 'GET', + $getStrGraphRequest + ))->execute()->getGraphObject()->asArray(); + + } catch (FacebookRequestException $e) { + echo "Exception occured, code: " . $e->getCode(); + echo " with message: " . $e->getMessage(); + } + return $this->convertRequestResultToArray($arrFBrequest); + } + private function convertRequestResultToArray($a = false) + { + // convert when its an object + if (is_object($a)) { + $a = get_object_vars($a); + } + // deeplink when array + if (is_array($a)) + return array_map(array($this, 'convertRequestResultToArray'), $a); + else + return $a; + } + + }; +?> \ No newline at end of file