コード例 #1
0
ファイル: Request.php プロジェクト: gigaai/framework
 /**
  * Setup data and run command based on received data
  */
 private function load()
 {
     self::$received = !empty($_REQUEST) ? $_REQUEST : json_decode(file_get_contents('php://input'));
     self::$token = Config::get('page_access_token');
     $this->verifyTokenFromFacebook();
     $this->subscribeFacebook();
     // Run thread settings
     ThreadSettings::init();
 }
コード例 #2
0
ファイル: Storage.php プロジェクト: gigaai/framework
 private function createConnection()
 {
     $this->db = new Capsule();
     $this->createConfigFromWordPress();
     $config = Config::get('mysql');
     $this->db->addConnection(['driver' => 'mysql', 'host' => $config['host'], 'database' => $config['database'], 'username' => $config['username'], 'password' => $config['password'], 'charset' => $config['charset'], 'collation' => $config['collation'], 'prefix' => $config['prefix']]);
     // Make this Capsule instance available globally via static methods... (optional)
     $this->db->setAsGlobal();
     $this->db->bootEloquent();
 }
コード例 #3
0
ファイル: ThreadSettings.php プロジェクト: gigaai/framework
 public static function updatePersistentMenu()
 {
     $menu = Config::get('persistent_menu');
     $end_point = Request::PLATFORM_ENDPOINT . 'me/thread_settings?access_token=' . Request::$token;
     $params = ['setting_type' => 'call_to_actions', 'thread_state' => 'existing_thread'];
     if (!empty($menu)) {
         $params['call_to_actions'] = $menu;
         return Request::send($end_point, $params);
     }
     Request::send($end_point, $params, 'delete');
 }
コード例 #4
0
ファイル: MessengerBot.php プロジェクト: gigaai/framework
 public function processEvent($event)
 {
     // Currently, we only handle message and postback
     if (!isset($event->message) && !isset($event->postback)) {
         return;
     }
     if (isset($event->message)) {
         $this->message = $event->message;
     }
     // If current message is send from Lead
     if (!$this->conversation->has('lead_id') && $event->sender->id != Config::get('page_id')) {
         $this->conversation->set('lead_id', $event->sender->id);
         // Save lead data if not exists.
         $this->storage->pull($event->sender->id);
     }
     DynamicParser::support(['type' => 'callback', 'callback' => function ($content) {
         return @call_user_func_array($content, [$this, $this->getLeadId(), $this->getReceivedText()]);
     }]);
     $type_pattern = $this->request->getTypeAndPattern($event);
     // We'll check to response intended action first
     if ($this->responseIntendedAction()) {
         return;
     }
     $nodes = $this->findNodes($type_pattern['type'], $type_pattern['pattern']);
     $this->response($nodes);
 }