public function viberSetWebhookAction() { $url = 'https://chatapi.viber.com/pa/set_webhook'; $jsonData='{ "auth_token": "' . VIBER_TOKEN_ONE . '", "url": "https://' . SITE_URL . '/viber-bot/webhook-page" }'; // file_put_contents(dirname(DIR) .'/Log/viber_bot.txt', 'Hello World'. PHP_EOL, FILE_APPEND | LOCK_EX); // $tempVar = json_decode($jsonData, true); // file_put_contents(dirname(DIR) .'/Log/viber_bot.txt', $tempVar['url'] . PHP_EOL, FILE_APPEND | LOCK_EX); $result = $this->viberSender->viberSenderJson($jsonData, $url); file_put_contents(dirname(DIR) .'/Log/Viber/turn-on-lighting.txt', 'None', LOCK_EX); return $result; }
public function viberSenderJson(string $jsonData, string $url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); return $result; }
Обсуждают сегодня