验证一个组播API的http请求参数中的是否正确
@param array $payload
@return boolean
161792
protected function verifyGroup(&$payload){
        
        // 消息格式如果错误不继续.
        if(!$this->verifyMessage($payload)){
            // 错误信息应有verifyMessage中生成.
            
            return false;
        }
            
        // 没有type,认为是push/tags的简单调用方式, 需要将type置为1
        $payload['type'] = array_key_exists('type', $payload) ? $payload['type'] : 1;
        
        if($payload['type']  === 1){
            // 必须要求有tag.
            if(!array_key_exists('tag', $payload)){
                $this->onError(null,3,'SDK params invalid, [tag] is required,  when the [type] not 2 ~ 6');
                return false;
            }
        }
        // type不等于1, 必须有selector
        else if(array_key_exists('selector', $payload)){             

            if(is_array($payload['selector'])){
                $payload['selector'] = json_encode($payload['selector']);
            }
            
        }
        // 其它情况,直接认为错误.
        else{
            $this->onError(null,3,'SDK params invalid, [selector] is required,  when the [type] between 2 and 6');
            return false;
        }
        
        return true;
    }
900569
function _filter($payload)
    {
        switch (ord($payload[0])) {
            case NET_SSH2_MSG_DISCONNECT:
                $this->_string_shift($payload, 1);
                extract(unpack('Nreason_code/Nlength', $this->_string_shift($payload, 8)));
                $this->errors[] = 'SSH_MSG_DISCONNECT: ' . $this->disconnect_reasons[$reason_code] . "\r\n" . utf8_decode($this->_string_shift($payload, $length));
                $this->bitmask = 0;
                return false;
            case NET_SSH2_MSG_IGNORE:
                $payload = $this->_get_binary_packet();
                break;
            case NET_SSH2_MSG_DEBUG:
                $this->_string_shift($payload, 2);
                extract(unpack('Nlength', $this->_string_shift($payload, 4)));
                $this->errors[] = 'SSH_MSG_DEBUG: ' . utf8_decode($this->_string_shift($payload, $length));
                $payload = $this->_get_binary_packet();
                break;
            case NET_SSH2_MSG_UNIMPLEMENTED:
                return false;
            case NET_SSH2_MSG_KEXINIT:
                if ($this->session_id !== false) {
                    if (!$this->_key_exchange($payload)) {
                        $this->bitmask = 0;
                        return false;
                    }
                    $payload = $this->_get_binary_packet();
                }
        }

        // see http://tools.ietf.org/html/rfc4252#section-5.4; only called when the encryption has been activated and when we haven't already logged in
        if (($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR) && !($this->bitmap & NET_SSH2_MASK_LOGIN) && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) {
            $this->_string_shift($payload, 1);
            extract(unpack('Nlength', $this->_string_shift($payload, 4)));
            $this->errors[] = 'SSH_MSG_USERAUTH_BANNER: ' . utf8_decode($this->_string_shift($payload, $length));
            $payload = $this->_get_binary_packet();
        }

        // only called when we've already logged in
        if (($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR) && ($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            switch (ord($payload[0])) {
                case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4
                    $this->_string_shift($payload, 1);
                    extract(unpack('Nlength', $this->_string_shift($payload)));
                    $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: ' . utf8_decode($this->_string_shift($payload, $length));

                    if (!$this->_send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE))) {
                        return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
                    }

                    $payload = $this->_get_binary_packet();
                    break;
                case NET_SSH2_MSG_CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1
                    $this->_string_shift($payload, 1);
                    extract(unpack('N', $this->_string_shift($payload, 4)));
                    $this->errors[] = 'SSH_MSG_CHANNEL_OPEN: ' . utf8_decode($this->_string_shift($payload, $length));

                    $this->_string_shift($payload, 4); // skip over client channel
                    extract(unpack('Nserver_channel', $this->_string_shift($payload, 4)));

                    $packet = pack('CN3a*Na*',
                        NET_SSH2_MSG_REQUEST_FAILURE, $server_channel, NET_SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED, 0, '', 0, '');

                    if (!$this->_send_binary_packet($packet)) {
                        return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
                    }

                    $payload = $this->_get_binary_packet();
                    break;
                case NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST:
                    $payload = $this->_get_binary_packet();
            }
        }

        return $payload;
    }
516833
protected function parsePayload($payload)
    {
        $database = 0;
        $client = null;

        $pregCallback = function ($matches) use (&$database, &$client) {
            if (2 === $count = \count($matches)) {
                // Redis <= 2.4
                $database = (int) $matches[1];
            }

            if (4 === $count) {
                // Redis >= 2.6
                $database = (int) $matches[2];
                $client = $matches[3];
            }

            return ' ';
        };

        $event = \preg_replace_callback('/ \(db (\d+)\) | \[(\d+) (.*?)\] /', $pregCallback, $payload, 1);
        @list($timestamp, $command, $arguments) = \explode(' ', $event, 3);

        return (object) [
            'timestamp' => (float) $timestamp,
            'database'  => $database,
            'client'    => $client,
            'command'   => \substr($command, 1, -1),
            'arguments' => $arguments,
        ];
    }
1177813
public function write($payload) {
		$this->coordinates->rewind();

		$size = strlen($payload);

		$header = pack("aVa", self::SOH, $size, self::STX);
		$footer = pack("aa", self::ETX, self::EOT);
		$payload = $header.$payload.$header;
		$size += strlen($header.$footer);

		if(ceil(count($this->coordinates) / 3) < $size) {
			// Image too small
			return false;
		}

 		for($cursor = 0; $cursor < $size; $cursor ++) {
			$byte = ord($payload[$cursor]);
			$this->writeByte($byte);
		}

		return true;
	}
214059
public function fillBlanks($payload)
    {
        $fields = ['doi', 'url', 'message', 'verbosemessage', 'responsecode', 'app_id'];
        foreach ($fields as $field) {
            if (!array_key_exists($field, $payload)) {
                $payload[$field] = "";
            }
        }
        return $payload;
    }
1231922
protected function validateRefresh(array $payload)
    {
        if (isset($payload['iat']) && Utils::timestamp($payload['iat'])->addMinutes($this->refreshTTL)->isPast()) {
            throw new TokenExpiredException('Token has expired and can no longer be refreshed', 400);
        }

        return true;
    }
1085751
private function setPayload($payload)
	{
		if ( (is_string($payload) && empty($payload)) || (is_array($payload) && count($payload) == 0) )
		{
			// Empty strings or arrays are not allowed
			throw new \InvalidArgumentException('Invalid payload for message. Payload was empty, but not null)');
		}
		else if (is_array($payload) || null === $payload)
		{
			if ( isset($payload['aps']) )
			{
				// Reserved key is used
				throw new \InvalidArgumentException('Invalid payload for message. Custom payload may not contain the reserved "aps" key.');
			}
			else
			{
				// This is okay, set as payload
				$this->payload = $payload;
			}
		}
		else
		{
			// Try to decode JSON string payload
			$payload = json_decode($payload, true);

			// Check if decoding the payload worked
			if (null === $payload) {
				throw new \InvalidArgumentException('Invalid payload for message. Payload was invalid JSON.');
			}

			// Set as payload
			$this->payload = $payload;
		}
	}
1048987
public function encode(Payload $payload)
    {
        $token = $this->provider->encode($payload->get());

        return new Token($token);
    }
1367864
public function respond($payload = [])
    {
        if ($meta = $this->getMeta()) {
            $payload = array_merge(
                $payload,
                ['meta' => $meta]
            );
        }

        if (config('api.convert')) {
            $payload = PayloadConverter::run($payload);
        }

        $statusCode = (config('api.suppress_response_code') === true)
            ? StatusCode::OK : $this->getStatusCode();

        return (! $callback = $this->request->input('callback'))
            ? $this->response->json(
                $payload,
                $statusCode,
                $this->getHeaders(),
                config('api.jsonEncodeOption')
            )
            : $this->response->jsonp(
                $callback,
                $payload,
                $statusCode,
                $this->getHeaders()
            );
    }
223336
function parseRequest( $payload )
    {
        if ( isset( $_SERVER['HTTP_SOAPACTION'] ) )
        {
            // this list of replacements built by testing different clients...
            // we should really parse the xml instead!
            $soapaction = trim( $_SERVER['HTTP_SOAPACTION'], '"' );
            $soapaction = preg_replace( array( '#^urn:#', '#^/*#', '#Action$#' ), '', $soapaction );
            $request = new ggPhpSOAPRequest( $soapaction );
            // this call is used to store the raw  xml in the request object
            $request->decodeStream( $payload );
            $request->setSoapVersion( 1 );
            return $request;
        }
        else
        {
            /*$request = new ggPhpSOAPRequest( '...' );
            $request->decodeStream( $payload );
            $request->setSoapVersion( 2 );
            return $request;*/
            return false;
        }
    }
636367
protected function verifyMessage(&$payload) {
        
        if (is_array($payload ['msg'])) {
            $payload ['msg'] = json_encode($payload ['msg']);
        }
        
        if (array_key_exists('send_time', $payload)) {
            if ($payload ['send_time'] < time() + 60) {
                $this -> onError(null, 3, "SDK params invalid, [send_time] must be greater than the current time + 60 seconds");
                return false;
            }
        }
        
        return true;
    }
607374
protected function getUserFromPayload(array $payload)
    {
        if (!isset($payload[$this->userIdClaim])) {
            throw $this->createAuthenticationException();
        }

        return $this->userProvider->loadUserByUsername($payload[$this->userIdClaim]);
    }
785510
public static function generateToken($payload = null)
    {
        if (empty($payload)) {
            return false;
        }

        $token = JWT::encode($payload, Configure::read('ApiRequest.jwtAuth.cypherKey'), Configure::read('ApiRequest.jwtAuth.tokenAlgorithm'));

        return $token;
    }
820529
public function serialize($payload)
    {
        $serialized = '';
        foreach ($payload as $line) {
            $serialized .= '"' . implode('","', $line) . '"' . "\n";
        }
        return $serialized;
    }
1136456
public function process($payload) {
        $result = $this->convertToObject($payload, true);

        return $this->processPayload($result);
    }
1074352
public function bind(array $payload=null)
    {
        $bound = false;
        $this->_boundEntities = array();

        if (!is_null($payload)
            && isset($payload[$this->getName()])
            && $this->validateSynchronizerToken($payload)
        ) {
            $this->logger->debug('start binding form', array('name' => $this->getName(), 'payload' => $payload));

            $propertyMapper = new PropertyMapper();

            $formOptions = $this->buildFormOptions($payload);

            if ($this->getEntityContainerMap()->count() > 0) {
                $entityContainers = $this->getEntityContainerMap()->getAll();

                /**
                 * @var $entityContainer    \Naucon\Form\Mapper\EntityContainerInterface
                 */
                foreach ($entityContainers as $entityContainer) {
                    $name = $entityContainer->getName();

                    if (is_null($formOptions) || in_array($name, $formOptions)) {
                        $this->_formOptionValues[] = $name;
                        if (isset($payload[$this->getName()][$name])) {
                            $formData = $payload[$this->getName()][$name];

                            $propertyMapper->mapFormToData($entityContainer->getEntity(), $formData);
                            $this->addBoundEntity($entityContainer->getEntity());

                            // postbind hook
                            $this->logger->debug('invoke form postbind hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                            $entityContainer->invokeHook('postbindHook');

                        }
                    } elseif (!is_null($formOptions) && !in_array($name, $formOptions)) {
                        $entityContainer->setValidate(false);
                    }
                }
            }

            switch($this->configuration->get('collection_type'))
            {
                case self::COLLECTION_TYPE_ONE:
                    if (count($this->getBoundEntities())==1) {
                        $bound = true;
                    }
                    break;
                case self::COLLECTION_TYPE_MANY:
                    if (count($this->getBoundEntities()) == count($this->_formOptionValues)) {
                        $bound = true;
                    }
                    break;
                case self::COLLECTION_TYPE_ALL:
                    if ($this->getEntityContainerMap()->count() == count($this->getBoundEntities())) {
                        $bound = true;
                    }
                    break;
                case self::COLLECTION_TYPE_ANY:
                    if ($this->getEntityContainerMap()->count() > 0) {
                        $bound = true;
                    }
                    break;
            }

        }

        $this->setBound($bound);

        $this->logger->debug('execute post binding form', array('name' => $this->getName()));
        $this->postBind();

        if ($this->isBound()) {
            $this->logger->debug('finished binding form successful', array('name' => $this->getName()));
        } else {
            $this->logger->debug('finished binding form failed', array('name' => $this->getName()));
        }
        return $this->isBound();
    }
1271547
public function fill($payload)
    {
        $payload = $this->determineTypeAndMessage($payload);
        $payload = $this->fillBlanks($payload);
        return $payload;
    }