コード例 #1
0
 /**
  * Makes a call to a Cloud function
  *
  * @param string $name Cloud function name
  * @param array  $data Parameters to pass
  * @param boolean $useMasterKey Whether to use the Master Key
  *
  * @return mixed
  */
 public static function run($name, $data = array(), $useMasterKey = false)
 {
     $sessionToken = null;
     if (ParseUser::getCurrentUser()) {
         $sessionToken = ParseUser::getCurrentUser()->getSessionToken();
     }
     $response = ParseClient::_request('POST', '/1/functions/' . $name, $sessionToken, json_encode(ParseClient::_encode($data, null, false)), $useMasterKey);
     return ParseClient::_decode($response['result']);
 }
コード例 #2
0
ファイル: SetOperation.php プロジェクト: uday21/order
 /**
  * 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} = $value;
         }
         return ParseClient::_encode($object, true);
     }
     return ParseClient::_encode($this->value, true);
 }
コード例 #3
0
ファイル: ParsePush.php プロジェクト: cocarson/MLink
 /**
  * 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 boolean $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) {
             $data['where'] = $data['where']->_getOptions()['where'];
         } else {
             throw new \Exception('Where parameter for Parse Push must be of type ParseQuery');
         }
     }
     if (isset($data['push_time'])) {
         $data['push_time'] = ParseClient::_encode($data['push_time'], false)['iso'];
     }
     if (isset($data['expiration_time'])) {
         $data['expiration_time'] = ParseClient::_encode($data['expiration_time'], false)['iso'];
     }
     return ParseClient::_request('POST', '/1/push', null, json_encode($data), $useMasterKey);
 }
コード例 #4
0
ファイル: ParsePush.php プロジェクト: jimlai1005/PTFast
 /**
  * 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 boolean $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) {
             $data['where'] = $data['where']->_getOptions()['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::getLocalPushDateFormat($data['push_time']);
     }
     if (isset($data['expiration_time'])) {
         $data['expiration_time'] = ParseClient::_encode($data['expiration_time'], false)['iso'];
     }
     return ParseClient::_request('POST', '/1/push', null, json_encode($data), $useMasterKey);
 }
コード例 #5
0
ファイル: ParseQuery.php プロジェクト: raxjethvaa/HTML
 /**
  * Build query string from query constraints.
  * @param array $queryOptions Associative array of the query constraints.
  *
  * @return string Query string.
  */
 private function buildQueryString($queryOptions)
 {
     if (isset($queryOptions["where"])) {
         $queryOptions["where"] = ParseClient::_encode($queryOptions["where"], true);
         $queryOptions["where"] = json_encode($queryOptions["where"]);
     }
     return http_build_query($queryOptions);
 }
コード例 #6
0
ファイル: AddUniqueOperation.php プロジェクト: uday21/order
 /**
  * Returns an associative array encoding of this operation.
  *
  * @return array
  */
 public function _encode()
 {
     return array('__op' => 'AddUnique', 'objects' => ParseClient::_encode($this->objects, true));
 }
コード例 #7
0
ファイル: ParseObject.php プロジェクト: uday21/order
 /**
  * Returns JSON object of the unsaved operations.
  *
  * @return array
  */
 private function getSaveJSON()
 {
     return ParseClient::_encode($this->operationSet, true);
 }
コード例 #8
0
 /**
  * Returns an associative array encoding of the current operation.
  *
  * @return mixed
  *
  * @throws \Exception
  */
 public function _encode()
 {
     $addRelation = array();
     $removeRelation = array();
     if (!empty($this->relationsToAdd)) {
         $addRelation = array('__op' => 'AddRelation', 'objects' => ParseClient::_encode(self::convertToOneDimensionalArray($this->relationsToAdd), true));
     }
     if (!empty($this->relationsToRemove)) {
         $removeRelation = array('__op' => 'RemoveRelation', 'objects' => ParseClient::_encode(self::convertToOneDimensionalArray($this->relationsToRemove), true));
     }
     if (!empty($addRelation) && !empty($removeRelation)) {
         return array('__op' => 'Batch', 'ops' => [$addRelation, $removeRelation]);
     }
     return empty($addRelation) ? $removeRelation : $addRelation;
 }
コード例 #9
0
ファイル: ParseCloud.php プロジェクト: borisavilov/Web
 /**
  * Makes a call to a Cloud function
  *
  * @param string $name Cloud function name
  * @param array  $data Parameters to pass
  * @param boolean $useMasterKey Whether to use the Master Key
  *
  * @return mixed
  */
 public static function run($name, $data = array(), $useMasterKey = false)
 {
     $response = ParseClient::_request('POST', '/1/functions/' . $name, null, json_encode(ParseClient::_encode($data, null, false)), $useMasterKey);
     return ParseClient::_decode($response['result']);
 }