Example #1
0
 /**
  * Initialize Push with needed Parse keys
  *
  * @param $appId
  * @param $restKey
  * @param $masterKey
  */
 public function __construct($appId, $restKey, $masterKey)
 {
     $this->appId = $appId;
     $this->restKey = $restKey;
     $this->masterKey = $masterKey;
     ParseClient::initialize($appId, $restKey, $masterKey);
 }
Example #2
0
 public static function setUp()
 {
     ini_set('error_reporting', E_ALL);
     ini_set('display_errors', 1);
     date_default_timezone_set('UTC');
     ParseClient::initialize('app-id-here', 'rest-api-key-here', 'master-key-here');
 }
 /**
  * Construct our adapter by gleaning the keys from the ENV params.
  * These can be set in the .env file, or set as environment vars on a production server.
  */
 public function __construct()
 {
     $app_id = env('PARSE_APP_APID');
     $rest_key = env('PARSE_APP_REST');
     $master_key = env('PARSE_APP_MAST');
     ParseClient::initialize($app_id, $rest_key, $master_key);
 }
 public static function setUp()
 {
     ini_set('error_reporting', E_ALL);
     ini_set('display_errors', 1);
     date_default_timezone_set('UTC');
     ParseClient::initialize('SVybRISVg4pUS0jciWYkZH5CSTyPaXAXvdWZjCu6', 'JthZqiVHiZ2BEEkwxWB2ltriJjmay3z7TRSS6KX5', 'RH4pRDW25piAJsMUEx3uduzvbSu2t9h37se77mNn');
 }
Example #5
0
 public function __construct()
 {
     parent::__construct();
     $this->load->database();
     //         Init parse: app_id, rest_key, master_key
     ParseClient::initialize($this->config->item('app_id'), $this->config->item('rest_key'), $this->config->item('master_key'));
 }
Example #6
0
 public function onBootstrap(MvcEvent $e)
 {
     //parse uses a global client, and needs the session to be started
     $config = $e->getApplication()->getServiceManager()->get('config');
     session_start();
     ParseClient::initialize($config['parse']['app_id'], $config['parse']['rest_key'], $config['parse']['master_key']);
 }
Example #7
0
 /**
  * Inicializa la aplicacion de la base de datos de Parse
  */
 public static function inicializa()
 {
     try {
         ParseClient::initialize('ve3SsAciKVt8GwhmLDCzW9rQ6EkPj8ai3pWcp3Is', 'zt0dVKAQwyRTAOFkfFj5d9jzDWAH9fjaJsUR5fhD', 'QpnJBJkOEp3VmEbcaAX8r6HDixj2wCUNQ42e1c4N');
     } catch (ParseException $ex) {
     }
 }
Example #8
0
 /**
  * Sends a push notification.
  *
  * @param array $data         The data of the push notification.    Valid fields
  *                            are:
  *                            channels - An Array of channels to push to.
  *                            push_time - A Date object for when to send the push.
  *                            expiration_time -    A Date object for when to expire
  *                            the push.
  *                            expiration_interval - The seconds from now to expire the push.
  *                            where - A ParseQuery over ParseInstallation that is used to match
  *                            a set of installations to push to.
  *                            data - The data to send as part of the push
  * @param bool  $useMasterKey Whether to use the Master Key for the request
  *
  * @throws \Exception, ParseException
  *
  * @return mixed
  */
 public static function send($data, $useMasterKey = false)
 {
     if (isset($data['expiration_time']) && isset($data['expiration_interval'])) {
         throw new Exception('Both expiration_time and expiration_interval can\'t be set.');
     }
     if (isset($data['where'])) {
         if ($data['where'] instanceof ParseQuery) {
             $where_options = $data['where']->_getOptions();
             if (!isset($where_options['where'])) {
                 $data['where'] = '{}';
             } else {
                 $dd = $data['where']->_getOptions();
                 $data['where'] = $dd['where'];
             }
         } else {
             throw new Exception('Where parameter for Parse Push must be of type ParseQuery');
         }
     }
     if (isset($data['push_time'])) {
         //Local push date format is different from iso format generally used in Parse
         //Schedule does not work if date format not correct
         $data['push_time'] = ParseClient::getPushDateFormat($data['push_time'], isset($data['local_time']));
     }
     if (isset($data['expiration_time'])) {
         $cc = ParseClient::_encode($data['expiration_time'], false);
         $data['expiration_time'] = $cc['iso'];
     }
     return ParseClient::_request('POST', 'push', null, json_encode(ParseClient::_encode($data, true)), $useMasterKey);
 }
 public static function setUpBeforeClass()
 {
     ParseClient::_unsetStorage();
     session_start();
     ParseTestHelper::setUp();
     self::$parseStorage = ParseClient::getStorage();
 }
 private function bootParseClient()
 {
     $config = $this->app['config']->get('parse');
     // Init the parse client
     ParseClient::initialize($config['app_id'], $config['rest_key'], $config['master_key']);
     ParseClient::setStorage(new ParseSessionStorage($this->app['session']));
 }
Example #11
0
 public function __construct()
 {
     $app_id = "id";
     $rest_key = "rest_key";
     $master_key = "master_key";
     ParseClient::initialize($app_id, $rest_key, $master_key);
 }
 /**
  * Setup parse.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupParse(Application $app)
 {
     $app_id = env('PARSE_APP_ID');
     $rest_key = env('PARSE_REST_KEY');
     $master_key = env('PARSE_MASTER_KEY');
     ParseClient::initialize($app_id, $rest_key, $master_key);
 }
Example #13
0
 public static function setUp()
 {
     ini_set('error_reporting', E_ALL);
     ini_set('display_errors', 1);
     date_default_timezone_set('UTC');
     ParseClient::initialize('app-id-here', 'rest-api-key-here', 'master-key-here', true, 'account-key-here');
     ParseClient::setServerURL('http://localhost:1337/parse');
 }
Example #14
0
 public static function email($type, $email, $title = "")
 {
     ParseClient::initialize(self::$app_id, self::$rest_key, self::$master_key);
     $alert = ["Nuevas validaciones disponibles", "Tiene un nuevo evento disponible", "Nuevas encuestas disponibles", "Tiene un nuevo mensaje"];
     $query = ParseInstallation::query();
     $query->equalTo("email", $email);
     ParsePush::send(array("where" => $query, "data" => array("title" => "VaClases", "alert" => ($title ? $title . " - " : "") . $alert[$type])));
 }
Example #15
0
 /**
  * Retrieves the Session object for the currently logged in user.
  *
  * @param boolean $useMasterKey If the Master Key should be used to override security.
  *
  * @return ParseSession
  */
 public static function getCurrentSession($useMasterKey = false)
 {
     $token = ParseUser::getCurrentUser()->getSessionToken();
     $response = ParseClient::_request('GET', '/1/sessions/me', $token, null, $useMasterKey);
     $session = new ParseSession();
     $session->_mergeAfterFetch($response);
     $session->handleSaveResult();
     return $session;
 }
Example #16
0
 public function connect_to_db()
 {
     //almacenamos en variables los datos obtenidos desde la clase Config
     $app_id = Config::appId;
     $rest_key = Config::restKey;
     $master_key = Config::masterKey;
     //establecemos la conexión a la DB
     $connection = ParseClient::initialize($app_id, $rest_key, $master_key);
 }
 public function __construct()
 {
     $appId = '**************';
     $restApiKey = '**************';
     $masterKey = '**************';
     // initialize parse
     ParseClient::initialize($appId, $restApiKey, $masterKey);
     // set session storage
     ParseClient::setStorage(new ParseSessionStorage());
 }
 /**
  * Creates a Transport instance
  *
  * @param array $config transport-specific configuration options
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
     $keys = Configure::read('Notifications.transports.push_message');
     if (Configure::check('Notifications.transports.push_message.' . ENVIRONMENT)) {
         // prefer environment specific config keys
         $keys = Configure::read('Notifications.transports.push_message.' . ENVIRONMENT);
     }
     ParseClient::initialize($keys['app_id'], $keys['rest_key'], $keys['master_key']);
 }
Example #19
0
 public function initialize()
 {
     // Initialize Parse Connection
     ParseClient::initialize('csuwC4xF8eEbruLrXFbVnWn9cfc3kdGwwphGDpuh', 'YFUTIzUHA9pejKqtLhBRldwP1JnjJqhkziLHGVaJ', 'XtZONCdSLK6fCIKPv6o4vmRbYfRrydduDTxjKZs1');
     // ------------------------ Asset Collections ------------------------
     // Css in the header
     $this->assets->collection('header')->addCss('plugins/pace/pace-theme-flash.css')->addCss('plugins/boostrapv3/css/bootstrap.min.css')->addCss('plugins/boostrapv3/css/bootstrap-theme.min.css')->addCss('plugins/font-awesome/css/font-awesome.css')->addCss('css/animate.min.css')->addCss('css/style.css')->addCss('css/responsive.css')->addCss('css/custom-icon-set.css');
     // Javascript in the footer
     $this->assets->collection('footer')->addJs('plugins/jquery-1.8.3.min.js')->addJs('plugins/boostrapv3/js/bootstrap.min.js')->addJs('plugins/pace/pace.min.js')->addJs('plugins/jquery-validation/js/jquery.validate.min.js')->addJs('plugins/jquery-lazyload/jquery.lazyload.min.js')->addJs('js/login_v2.js');
 }
Example #20
0
 public static function setUp()
 {
     $app_id = "8PYzxLlTqztkDEBCx3oDH6m6CqXYRpb4QTCWuuMw";
     $rest_key = "VUEHy9GWuE9SJdCn8wvScoWAMYWun6PbpzqP8KAh";
     $master_key = "WOyCyOO7gXaMs2wCqgwmBsWDxo8R7CIPhDH9baOM";
     ini_set('error_reporting', E_ALL);
     ini_set('display_errors', 1);
     date_default_timezone_set('UTC');
     ParseClient::initialize($app_id, $rest_key, $master_key);
 }
 /**
  * Returns an associative array encoding of the current operation.
  *
  * @return mixed
  */
 public function _encode()
 {
     if ($this->isAssociativeArray) {
         $object = new \stdClass();
         foreach ($this->value as $key => $value) {
             $object->{$key} = ParseClient::_encode($value, true);
         }
         return ParseClient::_encode($object, true);
     }
     return ParseClient::_encode($this->value, true);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Bool
  */
 public static function authenticated()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k'));
         $session = Cache::get('sessionToken', 'default');
         $user = ParseUser::become($session);
         return true;
     } catch (ParseException $error) {
         return false;
     }
 }
Example #23
0
 function __construct()
 {
     $this->imageResources = (object) ["groups" => [], "resources" => []];
     $this->imageResources->groups[] = (object) ["keys" => "tasks", "name" => "preload_task"];
     $this->imageResources->resources[] = (object) ["name" => "tasks", "type" => "json", "url" => $this->taskPath . DIRECTORY_SEPARATOR . "task.json"];
     if (!is_dir($this->fullPath2Images())) {
         mkdir($this->fullPath2Images(), 0777, true);
     }
     $parseCfgStr = file_get_contents($this->egretProjectPath . DIRECTORY_SEPARATOR . $this->resourcePath . DIRECTORY_SEPARATOR . "configs/php.json");
     $parseCfg = json_decode($parseCfgStr);
     ParseClient::initialize($parseCfg->app_id, $parseCfg->rest_key, $parseCfg->master_key);
 }
 /**
  * LOGOUT A USER
  *
  * @return void
  */
 public function logOut()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k'));
         $session = Cache::get('sessionToken', 'default');
         $user = ParseUser::become($session);
         Cache::forget('sessionToken');
         $user->logOut();
         return Redirect::to('login');
     } catch (ParseException $error) {
         dd($error);
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     Log::info("PARSE AUTH");
     try {
         ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k'));
         $session = Cache::get('sessionToken', 'default');
         $user = ParseUser::become($session);
         return $next($request);
     } catch (ParseException $error) {
         Log::info("PARSE AUTH ERROR: " . $error);
         return new RedirectResponse(url('/login'));
     }
 }
Example #26
0
 /**
  * Tracks the occurrence of a custom event with additional dimensions.
  * Parse will store a data point at the time of invocation with the given
  * event name.
  *
  * Dimensions will allow segmentation of the occurrences of this custom
  * event. Keys and values should be strings, and will throw
  * otherwise.
  *
  * To track a user signup along with additional metadata, consider the
  * following:
  * <pre>
  * $dimensions = array(
  *    'gender' => 'm',
  *    'source' => 'web',
  *    'dayType' => 'weekend'
  * );
  * ParseAnalytics::track('signup', $dimensions);
  * </pre>
  *
  * There is a default limit of 4 dimensions per event tracked.
  *
  * @param string $name       The name of the custom event
  * @param array  $dimensions The dictionary of segment information
  *
  * @throws \Exception
  *
  * @return mixed
  */
 public static function track($name, $dimensions = [])
 {
     $name = trim($name);
     if (strlen($name) === 0) {
         throw new Exception('A name for the custom event must be provided.');
     }
     foreach ($dimensions as $key => $value) {
         if (!is_string($key) || !is_string($value)) {
             throw new Exception('Dimensions expected string keys and values.');
         }
     }
     return ParseClient::_request('POST', 'events/' . $name, null, static::_toSaveJSON($dimensions));
 }
Example #27
0
 public function logout(Request $request, Response $response, $args)
 {
     $this->logger->info("Login page action dispatched");
     $uri = $request->getUri();
     try {
         $this->userRepository->logOut();
         $this->currentUser = $this->userRepository->getCurrentUser();
         ParseClient::getStorage()->set('company', null);
     } catch (ParseException $e) {
         ParseErrorHandler::handleParseError($e);
     }
     return $response->withStatus(302)->withHeader('Location', $uri->withPath('login'));
 }
Example #28
0
 public function login($data)
 {
     $app_id = 'yPPe3Uv46pKNnrTc7I6xArFHi8EQ8cdz4Kw3JGkX';
     $rest_key = '7PJB1F4g8aFSv5f8e0gSMwi9Ghv2AeAkTW0O50pe';
     $master_key = 'y95bItd5BI6Btqos1De4m8HZUllSM3HMcOs04WWB';
     try {
         ParseClient::initialize($app_id, $rest_key, $master_key);
         $user = ParseUser::logIn($data["username"], $data["password"]);
         $currentUser = ParseUser::getCurrentUser();
         //die('<pre>'.print_r($currentUser, true));
         return $currentUser;
     } catch (ParseException $e) {
         return false;
     }
 }
 public function processNotifications($batch_size)
 {
     $notifications_repository = $this->notifications_repository;
     return $this->tx_manager->transaction(function () use($batch_size, $notifications_repository) {
         $qty = 0;
         $query = new QueryObject();
         $query->addAndCondition(QueryCriteria::equal('IsSent', 0));
         list($list, $size) = $notifications_repository->getAll($query, 0, $batch_size);
         // init parse ...
         ParseClient::initialize(PARSE_APP_ID, PARSE_REST_KEY, PARSE_MASTER_KEY);
         foreach ($list as $notification) {
             if (empty($notification->Message)) {
                 continue;
             }
             $message = array("data" => array('alert' => $notification->Message));
             // Push to speakers
             try {
                 switch ($notification->Channel) {
                     case 'SPEAKERS':
                         $message['channels'] = ['speakers'];
                         break;
                     case 'ATTENDEES':
                         $message['channels'] = ['attendees'];
                         break;
                     case 'MEMBERS':
                         $recipients = array();
                         foreach ($notification->Recipients() as $m) {
                             array_push($recipients, 'me_' . $m->ID);
                         }
                         $message['channels'] = $recipients;
                         break;
                     case 'SUMMIT':
                         $message['channels'] = ['su_' . $notification->SummitID];
                         break;
                     case 'ALL':
                         $message['where'] = ParseInstallation::query();
                         break;
                 }
                 ParsePush::send($message);
                 $notification->sent();
                 ++$qty;
             } catch (Exception $ex) {
                 SS_Log::log($ex->getMessage(), SS_Log::ERR);
             }
         }
         return $qty;
     });
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k'));
         $condicoesJSON = Input::get('condicoes');
         $condicoes = json_decode($condicoesJSON);
         $protocoloId = Input::get('id');
         $protocoloQuery = new ParseQuery("Protocolo");
         $protocolo = $protocoloQuery->get($protocoloId);
         $condQuery = new ParseQuery("DescritivoMinimo");
         $condQuery->equalTo('protocolo', $protocolo);
         $condicoesFromServer = $condQuery->find();
         $condicoesArray = [];
         for ($serverIndex = 0; $serverIndex < count($condicoesFromServer); $serverIndex++) {
             $present = false;
             if (array_key_exists($serverIndex, $condicoesFromServer)) {
                 $keysArray = array_keys($condicoes);
                 for ($localIndex = 0; $localIndex < count($keysArray); $localIndex++) {
                     if (array_key_exists($keysArray[$localIndex], $condicoes)) {
                         if ($condicoes[$keysArray[$localIndex]]->id == $condicoesFromServer[$serverIndex]->getObjectId()) {
                             $present = true;
                             $condicoesFromServer[$serverIndex]->set('ordem', $condicoes[$keysArray[$localIndex]]->ordem);
                             $condicoesFromServer[$serverIndex]->save();
                             $condicoesArray[$condicoes[$keysArray[$localIndex]]->ordem] = $condicoesFromServer[$serverIndex]->getObjectId();
                             unset($condicoes[$keysArray[$localIndex]]);
                         }
                     }
                 }
                 if ($present == false) {
                     $condicoesFromServer[$serverIndex]->destroy();
                 }
             }
         }
         $keysArray = array_keys($condicoes);
         for ($index = 0; $index < count($keysArray); $index++) {
             $condicao = new ParseObject("DescritivoMinimo");
             $condicao->set('frase', $condicoes[$keysArray[$index]]->frase);
             $condicao->set('ordem', $condicoes[$keysArray[$index]]->ordem);
             $condicao->set('protocolo', $protocolo);
             $condicao->save();
             $condicoesArray[$condicoes[$keysArray[$index]]->ordem] = $condicao->getObjectId();
         }
         return json_encode($condicoesArray);
     } catch (ParseException $error) {
         dd($error);
         return $error;
     }
 }