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


PHP JsonHelper::getJson方法代码示例

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


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

示例1: getMessages

 /**
  * Gets Message based upon some filters
  * @param mixed $start The date to start querying from.
  * @param mixed $end The last possible time in the query.
  * @param integer $index The number of results to skip from the result set. The default is 0.
  * @param integer $limit The maximum number of results to return. This has a hard limit of 1000 messages.
  * @param boolean $pending A true or false value used to indicate if only scheduled messages should be returned in the result set. By default only sent message are returned
  * @param string $direction Used to filter the result by the direction of the message. Possible values are "in" (to return only inbound messages) and "out" (to return only outbound messages).
  * @return ApiList|HttpResponse|null
  * @throws ErrorException
  */
 public function getMessages($start = null, $end = null, $index = null, $limit = null, $pending = null, $direction = null)
 {
     $resource = "/messages/";
     if (!is_null($start)) {
         if (!is_int($start) || !is_string($start)) {
             throw new ErrorException("Parameter 'start' must be an integer Unix timestamp or a string time in this format (YYYY-MM-DD HH:MM:SS)");
         }
         if (is_string($start)) {
             if (!CommonUtil::is_datetime($time)) {
                 throw new ErrorException("Parameter 'start' must be a string time in this format (YYYY-MM-DD HH:MM:SS)");
             }
         }
         if (is_int($start) && $start < 0) {
             throw new ErrorException("Parameter 'start' must be a positive integer");
         }
     }
     if (!is_null($end)) {
         if (!is_int($end) || !is_string($end)) {
             throw new ErrorException("Parameter 'end' must be an integer Unix timestamp or a string time in this format (YYYY-MM-DD HH:MM:SS)");
         }
         if (is_string($end)) {
             if (!CommonUtil::is_datetime($time)) {
                 throw new ErrorException("Parameter 'end' must be a string time in this format (YYYY-MM-DD HH:MM:SS)");
             }
         }
         if (is_int($end) && $end < 0) {
             throw new ErrorException("Parameter 'end' must be a positive integer");
         }
     }
     if (!is_null($index) && !is_int($index)) {
         throw new ErrorException("Parameter 'index' must be an integer");
     }
     if (!is_null($limit) && !is_int($limit)) {
         throw new ErrorException("Parameter 'limit' must be an integer");
     }
     if (!is_null($pending) && (!CommonUtil::is_boolean($pending) || !is_bool($pending))) {
         throw new ErrorException("Parameter 'pending' must be a boolean (1, 0, true, false)");
     }
     if (!is_null($direction)) {
         if (!is_string($direction)) {
             throw new ErrorException("Parameter 'direction' must be string");
         } elseif ($direction !== MessageDirection::IN || $direction !== MessageDirection::OUT) {
             throw new ErrorException("Parameter 'direction' must be string. Possible values are in or out");
         }
     }
     try {
         $params = array();
         if (!is_null($start)) {
             $params["start"] = is_string($start) ? $start : gmdate('Y-m-d H:i:s', $start);
         }
         if (!is_null($end)) {
             $params["end"] = is_string($end) ? $end : gmdate('Y-m-d H:i:s', $end);
         }
         if (!is_null($index)) {
             $params["index"] = $index > 0 ? $index : 0;
         }
         if (!is_null($limit)) {
             $params["limit"] = $limit > 0 && $limit <= 1000 ? $limit : 1000;
         }
         if (!is_null($pending)) {
             if ($pending === "true" || $pending || $pending === "1") {
                 $params["pending"] = "true";
             }
             if ($pending === "false" || $pending === false || $pending === "0") {
                 $params["pending"] = "false";
             }
         }
         if (!is_null($direction)) {
             $params["direction"] = $direction;
         }
         $response = $this->httpClient->get($resource, $params);
         if ($response instanceof HttpResponse) {
             if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
                 $json = JsonHelper::getJson($response->getBody());
                 if (isset($json)) {
                     return new ApiList($json);
                 }
             } else {
                 return $response;
             }
         }
     } catch (Exception $ex) {
         echo $ex->getTraceAsString();
     }
     return null;
 }
开发者ID:fredrickabayie,项目名称:MyBankWeb,代码行数:97,代码来源:MessagingApi.php

示例2: addContactGroup

 /**
  * Creates a new Contact Group
  * @param mixed $group The contact group data. It can be an associative array or an instance of ContactGroup
  * @return HttpResponse|null|ContactGroup
  * @throws ErrorException
  */
 public function addContactGroup($group)
 {
     $resource = "/contacts/groups/";
     if (is_null($group)) {
         throw new ErrorException("Parameter 'group' cannot be null");
     }
     if (!is_string($group) || !$group instanceof ContactGroup || !is_array($group)) {
         throw new ErrorException("Parameter 'group' must be of type ContactGroup or an array or a string");
     }
     try {
         $params = array();
         if (is_string($group)) {
             $params["Name"] = $group;
         } else {
             $params = is_array($group) ? $group : json_decode(JsonHelper::toJson($group), true);
         }
         $response = $this->httpClient->post($resource, $params);
         if ($response instanceof HttpResponse) {
             if ($response->getStatus() === HttpStatusCode::HTTP_CREATED) {
                 $json = JsonHelper::getJson($response->getBody());
                 if (isset($json)) {
                     return new ContactGroup($json);
                 }
             } else {
                 return $response;
             }
         }
     } catch (\Exception $ex) {
         echo $ex->getTraceAsString();
     }
     return null;
 }
开发者ID:natino45,项目名称:smsghapi-php,代码行数:38,代码来源:ContactApi.php

示例3: updateSupportTicket

 /**
  * Replies to a Support Ticket
  * @param integer $ticketId
  * @param mixed $request
  * @return HttpResponse|null|Ticket
  * @throws \ErrorException
  */
 public function updateSupportTicket($ticketId, $request)
 {
     $resource = "/tickets/";
     if (is_null($ticketId)) {
         throw new \ErrorException("Parameter 'ticketId' cannot be null");
     } elseif (!is_int($ticketId)) {
         throw new \ErrorException("Parameter 'ticketId' must be an integer");
     }
     if (is_null($request)) {
         throw new \ErrorException("Parameter 'request' cannot be null");
     } elseif (!$request instanceof TicketResponse || !is_array($request)) {
         throw new \ErrorException("Parameter 'request' must be of type TicketResponse or an array");
     }
     try {
         $params = array();
         $params = is_array($request) ? $request : json_decode(JsonHelper::toJson($request), true);
         $response = $this->httpClient->put($resource, $params);
         if ($response instanceof HttpResponse) {
             if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
                 $json = JsonHelper::getJson($response->getBody());
                 if (isset($json)) {
                     return new Ticket($json);
                 }
             } else {
                 return $response;
             }
         }
     } catch (\Exception $ex) {
         echo $ex->getTraceAsString();
     }
     return null;
 }
开发者ID:natino45,项目名称:smsghapi-php,代码行数:39,代码来源:SupportApi.php

示例4: updateContentMedia

 /**
  * Updates the details of an existing content media.
  * @param UUID $mediaId The content media
  * @param MediaInfo $mediaInfo The content media details
  * @return HttpResponse|ContentMedia|null
  * @throws ErrorException
  */
 public function updateContentMedia($mediaId, $mediaInfo = null)
 {
     $resource = "/media/";
     if (is_null($mediaId)) {
         throw new ErrorException("Parameter 'mediaId' cannot be null");
     } elseif (!CommonUtil::is_uuid($mediaId)) {
         throw new ErrorException("Parameter 'mediaId' must be a valid UUID");
     }
     if (!is_null($mediaInfo) && !$mediaInfo instanceof MediaInfo) {
         throw new ErrorException("Parameter 'mediaInfo' cannot be null and must be an instance of MediaInfo.");
     }
     try {
         $resource .= $mediaId;
         // Set the mediainfo data
         $params["ContentName"] = $mediaInfo->contentName;
         $params["LibraryId"] = $mediaInfo->libraryId;
         $params["DestinationFolder"] = $mediaInfo->destinationFolder;
         $params["Preference"] = $mediaInfo->preference;
         $params["Width"] = $mediaInfo->width;
         $params["Height"] = $mediaInfo->height;
         $params["DrmProtect"] = $mediaInfo->drmProtect;
         $params["Streamable"] = $mediaInfo->streamable;
         $params["DisplayText"] = $mediaInfo->displayText;
         $params["ContentText"] = $mediaInfo->contentText;
         $params["Tags"] = "";
         // set the medainfo tags
         if (!is_null($mediaInfo->tags) && is_array($mediaInfo->tags) && count($mediaInfo->tags) > 0) {
             $params["Tags"] = JsonHelper::toJson($mediaInfo->tags);
         }
         $response = $this->httpClient->put($resource, $params);
         if ($response instanceof HttpResponse) {
             if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
                 $json = JsonHelper::getJson($response->getBody());
                 if (isset($json)) {
                     return new ContentMedia($json);
                 }
             } else {
                 return $response;
             }
         }
     } catch (Exception $ex) {
         $ex->getTraceAsString();
     }
     return null;
 }
开发者ID:fredrickabayie,项目名称:MyBankWeb,代码行数:52,代码来源:ContentApi.php

示例5: getVoucher

 /**
  * Get a voucher topup
  * @param string $voucherNumber
  * @return HttpResponse|Topup|null
  * @throws ErrorException
  */
 public function getVoucher($voucherNumber)
 {
     $resource = "/topup/voucher/";
     if (is_null($voucherNumber)) {
         throw new ErrorException("Parameter 'voucherNumber' cannot be null");
     } elseif (!is_string($voucherNumber)) {
         throw new ErrorException("Parameter 'voucherNumber' must be a string");
     }
     try {
         $resource .= $voucherNumber;
         $response = $this->httpClient->get($resource);
         if ($response instanceof HttpResponse) {
             if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
                 $json = JsonHelper::getJson($response->getBody());
                 if (isset($json)) {
                     return new Topup($json);
                 }
             } else {
                 return $response;
             }
         }
     } catch (Exception $ex) {
         echo $ex->getTraceAsString();
     }
     return null;
 }
开发者ID:fredrickabayie,项目名称:MyBankWeb,代码行数:32,代码来源:AccountApi.php


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