jsonValidate() 공개 정적인 메소드

JSON validation
public static jsonValidate ( string $jsonString, boolean $asArray ) : object | array
$jsonString string
$asArray boolean
리턴 object | array
예제 #1
0
파일: Botan.php 프로젝트: zzbomb/Api
 /**
  * Event tracking
  *
  * @param \TelegramBot\Api\Types\Message $message
  * @param string $eventName
  *
  * @throws \TelegramBot\Api\Exception
  * @throws \TelegramBot\Api\HttpException
  */
 public function track(Message $message, $eventName = 'Message')
 {
     $uid = $message->getFrom()->getId();
     $options = [CURLOPT_URL => self::BASE_URL . "?token={$this->token}&uid={$uid}&name={$eventName}", CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_POSTFIELDS => $message->toJson()];
     curl_setopt_array($this->curl, $options);
     $result = BotApi::jsonValidate(curl_exec($this->curl), true);
     BotApi::curlValidate($this->curl);
     if ($result['status'] !== 'accepted') {
         throw new Exception('Error Processing Request');
     }
 }
예제 #2
0
파일: Client.php 프로젝트: baravak/Api
 /**
  * Webhook handler
  *
  * @return array
  * @throws \TelegramBot\Api\InvalidJsonException
  */
 public function run()
 {
     if ($data = BotApi::jsonValidate($this->getRawBody(), true)) {
         $this->handle([Update::fromResponse($data)]);
     }
 }
예제 #3
0
파일: Client.php 프로젝트: zzbomb/Api
 /**
  * Webhook handler
  *
  * @return array
  * @throws \TelegramBot\Api\InvalidJsonException
  */
 public function run()
 {
     if ($data = BotApi::jsonValidate(file_get_contents('php://input'), true)) {
         $this->handle([Update::fromResponse($data)]);
     }
 }