当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getContent方法代码示例

本文整理汇总了PHP中Zend\Http\Request::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getContent方法的具体用法?PHP Request::getContent怎么用?PHP Request::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Http\Request的用法示例。


在下文中一共展示了Request::getContent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: receiveRequest

 public function receiveRequest(HttpRequest $request)
 {
     /**
      * Iterate over all events found in the body of the request
      * and for each of these trigger an event containing the event data
      */
     $eventData = json_decode($request->getContent(), true);
     $manager = $this->getEventManager();
     $params = ['requestBody' => $request->getContent(), 'error' => false];
     /**
      * Make sure that we have an array of Send Grid events
      */
     if (!is_array($eventData)) {
         $params['message'] = 'Invalid JSON Body, or unable to decode JSON payload';
         $params['error'] = true;
         $manager->trigger(self::EVENT_UNEXPECTED_FORMAT, $this, $params);
         return;
     }
     /**
      * Iterate over each Send Grid Event and trigger internal event for each
      */
     foreach ($eventData as $event) {
         $event['event'] = !isset($event['event']) ? null : $event['event'];
         $eventName = $this->resolveEventName($event['event']);
         $eventParams = $params;
         if ($eventName === self::EVENT_UNEXPECTED_TYPE) {
             $eventParams['error'] = true;
             $eventParams['message'] = 'Unexpected Event Type';
         }
         $eventParams['data'] = $event;
         $manager->trigger($eventName, $this, $eventParams);
     }
 }
开发者ID:netglue,项目名称:sendgrid-webhook,代码行数:33,代码来源:EventEmitter.php

示例2: parse

 /**
  * Parse the incoming request body
  *
  * Returns any discovered data parameters.
  *
  * @return array
  */
 public function parse()
 {
     if ($this->request instanceof Request) {
         return $this->parseFromStream($this->request->getContentAsStream());
     }
     $stream = fopen('php://temp', 'r+');
     fwrite($stream, $this->request->getContent());
     rewind($stream);
     return $this->parseFromStream($stream);
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:17,代码来源:MultipartContentParser.php

示例3: getId

 /**
  * Look for the ID in the request
  * @param Request $request
  * @param string $name
  * @return int
  */
 private function getId(Request $request, $name)
 {
     $id = $request->getPost($name);
     if (!$id) {
         $decoded = json_decode($request->getContent(), JSON_OBJECT_AS_ARRAY);
         if (is_array($decoded) && array_key_exists($name, $decoded)) {
             $id = $decoded[$name];
         }
     }
     return $id;
 }
开发者ID:Theodia,项目名称:theodia.org,代码行数:17,代码来源:ResourceResolverListener.php

示例4: fromZend

 /**
  * Convert a Zend\Http\Response in a PSR-7 response, using zend-diactoros
  *
  * @param  ZendRequest $zendRequest
  * @return ServerRequest
  */
 public static function fromZend(ZendRequest $zendRequest)
 {
     $body = new Stream('php://memory', 'wb+');
     $body->write($zendRequest->getContent());
     $headers = empty($zendRequest->getHeaders()) ? [] : $zendRequest->getHeaders()->toArray();
     $query = empty($zendRequest->getQuery()) ? [] : $zendRequest->getQuery()->toArray();
     $post = empty($zendRequest->getPost()) ? [] : $zendRequest->getPost()->toArray();
     $files = empty($zendRequest->getFiles()) ? [] : $zendRequest->getFiles()->toArray();
     $request = new ServerRequest([], self::convertFilesToUploaded($files), $zendRequest->getUriString(), $zendRequest->getMethod(), $body, $headers);
     $request = $request->withQueryParams($query);
     return $request->withParsedBody($post);
 }
开发者ID:MidnightDesign,项目名称:zend-psr7bridge,代码行数:18,代码来源:Psr7ServerRequest.php

示例5: testRequestPersistsRawBody

 public function testRequestPersistsRawBody()
 {
     $request = new Request();
     $request->setContent('foo');
     $this->assertEquals('foo', $request->getContent());
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:6,代码来源:RequestTest.php

示例6: handle

 /**
  * (non-PHPdoc)
  * @see Tinebase_Server_Interface::handle()
  */
 public function handle(\Zend\Http\Request $request = null, $body = null)
 {
     $this->_request = $request instanceof \Zend\Http\Request ? $request : Tinebase_Core::get(Tinebase_Core::REQUEST);
     if ($body !== null) {
         $this->_body = $body;
     } else {
         if ($this->_request instanceof \Zend\Http\Request) {
             $this->_body = fopen('php://temp', 'r+');
             fwrite($this->_body, $request->getContent());
             rewind($this->_body);
         }
     }
     try {
         list($loginName, $password) = $this->_getAuthData($this->_request);
     } catch (Tinebase_Exception_NotFound $tenf) {
         header('WWW-Authenticate: Basic realm="WebDAV for Tine 2.0"');
         header('HTTP/1.1 401 Unauthorized');
         return;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is CalDav, CardDAV or WebDAV request.');
     }
     Tinebase_Core::initFramework();
     if (Tinebase_Controller::getInstance()->login($loginName, $password, $this->_request, self::REQUEST_TYPE) !== true) {
         header('WWW-Authenticate: Basic realm="WebDAV for Tine 2.0"');
         header('HTTP/1.1 401 Unauthorized');
         return;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' requestUri:' . $this->_request->getRequestUri());
     }
     self::$_server = new \Sabre\DAV\Server(new Tinebase_WebDav_Root());
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         $contentType = self::$_server->httpRequest->getHeader('Content-Type');
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " requestContentType: " . $contentType);
         if (preg_match('/^text/', $contentType)) {
             // NOTE inputstream can not be rewinded
             $debugStream = fopen('php://temp', 'r+');
             stream_copy_to_stream($this->_body, $debugStream);
             rewind($debugStream);
             $this->_body = $debugStream;
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " <<< *DAV request\n" . stream_get_contents($this->_body));
             rewind($this->_body);
         } else {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " <<< *DAV request\n -- BINARY DATA --");
         }
     }
     self::$_server->httpRequest->setBody($this->_body);
     // compute base uri
     self::$_server->setBaseUri($this->_request->getBaseUrl() . '/');
     $tempDir = Tinebase_Core::getTempDir();
     if (!empty($tempDir)) {
         self::$_server->addPlugin(new \Sabre\DAV\Locks\Plugin(new \Sabre\DAV\Locks\Backend\File($tempDir . '/webdav.lock')));
     }
     self::$_server->addPlugin(new \Sabre\DAV\Auth\Plugin(new Tinebase_WebDav_Auth(), null));
     $aclPlugin = new \Sabre\DAVACL\Plugin();
     $aclPlugin->defaultUsernamePath = Tinebase_WebDav_PrincipalBackend::PREFIX_USERS;
     $aclPlugin->principalCollectionSet = array(Tinebase_WebDav_PrincipalBackend::PREFIX_USERS, Tinebase_WebDav_PrincipalBackend::PREFIX_GROUPS);
     $aclPlugin->principalSearchPropertySet = array('{DAV:}displayname' => 'Display name', '{' . \Sabre\DAV\Server::NS_SABREDAV . '}email-address' => 'Email address', '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}email-address-set' => 'Email addresses', '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}first-name' => 'First name', '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}last-name' => 'Last name', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-user-address-set' => 'Calendar user address set', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-user-type' => 'Calendar user type');
     self::$_server->addPlugin($aclPlugin);
     self::$_server->addPlugin(new \Sabre\CardDAV\Plugin());
     self::$_server->addPlugin(new Calendar_Frontend_CalDAV_SpeedUpPlugin());
     // this plugin must be loaded before CalDAV plugin
     self::$_server->addPlugin(new \Sabre\CalDAV\Plugin());
     self::$_server->addPlugin(new \Sabre\CalDAV\SharingPlugin());
     self::$_server->addPlugin(new Calendar_Frontend_CalDAV_PluginAutoSchedule());
     self::$_server->addPlugin(new Calendar_Frontend_CalDAV_PluginDefaultAlarms());
     self::$_server->addPlugin(new Calendar_Frontend_CalDAV_PluginManagedAttachments());
     self::$_server->addPlugin(new Calendar_Frontend_CalDAV_PluginPrivateEvents());
     self::$_server->addPlugin(new Tinebase_WebDav_Plugin_Inverse());
     self::$_server->addPlugin(new Tinebase_WebDav_Plugin_OwnCloud());
     self::$_server->addPlugin(new Tinebase_WebDav_Plugin_PrincipalSearch());
     #self::$_server->addPlugin(new DAV\Sync\Plugin());
     self::$_server->addPlugin(new \Sabre\DAV\Browser\Plugin());
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         ob_start();
     }
     self::$_server->exec();
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " >>> *DAV response:\n" . ob_get_contents());
         ob_end_flush();
     }
     Tinebase_Controller::getInstance()->logout($this->_request->getServer('REMOTE_ADDR'));
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:88,代码来源:WebDAV.php

示例7: authenticate

    /**
     * Attempt to authenticate the current request.
     *
     * @param Request $request
     * @param Response $response
     * @param MvcAuthEvent $mvcAuthEvent
     * @return false|IdentityInterface False on failure, IdentityInterface
     *     otherwise
     */
    public function authenticate(Request $request, Response $response, MvcAuthEvent $mvcAuthEvent)
    {
        $content       = $request->getContent();
        $oauth2request = new OAuth2Request(
            $_GET,
            $_POST,
            array(),
            $_COOKIE,
            $_FILES,
            $_SERVER,
            $content,
            $request->getHeaders()->toArray()
        );

        if (! $this->oauth2Server->verifyResourceRequest($oauth2request)) {
            return false;
        }

        $token    = $this->oauth2Server->getAccessTokenData($oauth2request);
        $identity = new Identity\AuthenticatedIdentity($token);
        $identity->setName($token['user_id']);
        return $identity;
    }
开发者ID:jbarentsen,项目名称:drb,代码行数:32,代码来源:OAuth2Adapter.php

示例8: getBodyData

 protected static function getBodyData(Request $request = null)
 {
     $result = array();
     if ($request !== null) {
         $content = $request->getContent();
         if (!empty($content)) {
             try {
                 $result = Json::decode($content, Json::TYPE_ARRAY);
             } catch (\RuntimeException $e) {
             }
         }
     }
     return $result;
 }
开发者ID:fousheezy,项目名称:common,代码行数:14,代码来源:Params.php

示例9: negotiateContent

 /**
  * Negotiates the request payload.
  *
  * @param \BedRest\Rest\Request\Request                $restRequest
  * @param \Zend\Http\Request                           $httpRequest
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  */
 protected function negotiateContent(RestRequest $restRequest, HttpRequest $httpRequest, ServiceLocatorInterface $serviceLocator)
 {
     $content = $httpRequest->getContent();
     $contentType = $httpRequest->getHeader('Content-Type');
     if (!empty($content) && !empty($contentType)) {
         /** @var \BedRest\Content\Negotiation\Negotiator $negotiator */
         $negotiator = $serviceLocator->get('BedRest.ContentNegotiator');
         $restRequest->setContent($negotiator->decode($content, $contentType->value));
         $restRequest->setContentType($contentType);
     }
 }
开发者ID:bedrest,项目名称:framework-zendframework2,代码行数:18,代码来源:RequestFactory.php


注:本文中的Zend\Http\Request::getContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。