예제 #1
0
 /**
  * @param string $method
  * @param string $endpoint
  * @param array  $parameters
  * @param string $token
  *
  * @return \Facebook\FacebookResponse
  */
 private function executeFacebookRequest($method, $endpoint, array $parameters = [], $token = null)
 {
     if (is_callable($this->logCallback)) {
         //used only for debugging:
         call_user_func($this->logCallback, 'Facebook API request', func_get_args());
     }
     if (!$token) {
         $token = $this->appToken;
     }
     switch ($method) {
         case 'GET':
             $response = $this->fb->get($endpoint, $token);
             break;
         case 'POST':
             $response = $this->fb->post($endpoint, $parameters, $token);
             break;
         case 'DELETE':
             $response = $this->fb->delete($endpoint, $parameters, $token);
             break;
         default:
             throw new \Exception("Facebook driver exception, please add support for method: " . $method);
             break;
     }
     if (is_callable($this->logCallback)) {
         call_user_func($this->logCallback, 'Facebook API response', $response->getDecodedBody());
     }
     return $response;
 }