示例#1
0
 /**
  * Parses a HTTP request body.
  * @param string $rawBody the raw HTTP request body.
  * @param string $contentType the content type specified for the request body.
  * @return array parameters parsed from the request body
  * @throws RequestException
  */
 public function parse($rawBody, $contentType)
 {
     try {
         return Json::decode($rawBody, $this->asArray);
     } catch (\Exception $e) {
         if ($this->throwException) {
             throw new RequestException('Invalid JSON data in request body: ' . $e->getMessage(), [], $e);
         }
         return null;
     }
 }
示例#2
0
文件: Google.php 项目: romeoz/rock
 /**
  * {@inheritdoc}
  */
 public function getAttributes($code = null)
 {
     if (!isset($code)) {
         $code = Request::get('code');
     }
     if (empty($code)) {
         return [];
     }
     // This was a callback request from google, get the token
     $this->service->requestAccessToken($code);
     // Send a request with it
     try {
         return Json::decode($this->service->request($this->apiUrl));
     } catch (JsonException $e) {
         if (class_exists('\\rock\\log\\Log')) {
             Log::err(BaseException::convertExceptionToString($e));
         }
     }
     return [];
 }