public function connect(Connection $connection, ConnectionParameters $connectionParameters)
 {
     $sessions = [Connection::SESSION_CURL => new FacebookSessionBuilder($connectionParameters->getEmail(), $connectionParameters->getPassword()), Connection::SESSION_GRAPH => new FacebookGraphSessionBuilder($connectionParameters->getAppId(), $connectionParameters->getAppSecret(), $connectionParameters->getAccessToken())];
     array_walk($sessions, function (&$item) {
         $item = $item->build();
     });
     $connection->setState(new ConnectedConnectionState($sessions));
 }
 /**
  * Handles a single membership request entity by approving it.
  *
  * @param Connection $connection The connection to use for requests.
  * @param MemberRequestEntity $entity The entity to handle.
  *
  * @throws ConnectionException If something goes wrong with the connection.
  */
 protected function handleEntity(Connection $connection, $entity)
 {
     $connection->request(Connection::REQ_LITE, $entity->getActionUrl(), 'POST', $entity->getInputData());
 }
 /**
  * Scans the comments for admin comments in the past.
  */
 private function isHandled(Connection $connection, $postId)
 {
     $params = ['fields' => 'message', 'limit' => 500];
     $path = "/{group_id}_{$postId}/comments";
     $response = $connection->request(Connection::REQ_GRAPH, $path, 'GET', $params);
     $comments = $response->getGraphObjectList();
     foreach ($comments as $comment) {
         if (strpos($comment->getProperty('message'), '[admin]') === 0) {
             return true;
         }
     }
     return false;
 }
 public function disconnect(Connection $connection)
 {
     $connection->setState(new DisconnectedConnectionState());
 }