File manager - Edit - /home/autoph/public_html/tasks/api/v1/viber/send_video_notification.php
Back
<?php // echo $_REQUEST['json'];exit; /** * Before you run this example: * 1. install monolog/monolog: composer require monolog/monolog * 2. copy config.php.dist to config.php: cp config.php.dist config.php * * @author Novikov Bogdan <hcbogdan@gmail.com> */ //sample json request // {"target_id":"80","type":1,"target_json":["262","292"]} require_once("../../../vendor/autoload.php"); include_once '../../../cfg/db_console.php'; use Viber\Bot; use Viber\Api\Sender; // use Monolog\Logger; // use Monolog\Handler\StreamHandler; $apiKey = '4ea7a840c9e7e7da-6455ceb946c2433c-569e8f349ab53511'; // reply name $botSender = new Sender([ 'name' => 'TASKS', 'avatar' => 'https://connect.autohub.ph/dist/img/default.png', ]); try { if(!isset($_REQUEST['json']) || is_null(json_decode($_REQUEST['json']))){ $json_arr['status'] = 0; $json_arr['message'] = "Invalid parameters."; echo json_encode($json_arr); exit; } include_once dirname(__FILE__) . '../../../../app/classes/user_class.php'; $user_class = new User(); $param_json = json_decode($_REQUEST['json'], true); $type = $param_json['type']; $target_id = $param_json['target_id']; $target_position_arr = $param_json['target_json']; //get target id details $video_title = $db->select("SELECT title FROM `videos` WHERE id = $target_id"); $query = "SELECT u.*,ati.api_id FROM `users` u LEFT OUTER JOIN cnf_api_token_ids ati ON u.id = ati.user_id WHERE 1 AND u.position_id IN (".implode(",",$target_position_arr).") AND ati.type = $type AND ati.status = 1;"; // echo $query; $user_obj = $db->sql_query($query); $user_arr = array(); foreach($user_obj as $user_row){ // $user_arr = array_merge($user_arr,array($user_row)); $user_arr[] = $user_row; } foreach($user_arr as $user_row1){ $token = $db->select('SELECT UUID()'); $to_user_id = $user_row1['id']; $from_user_id = $user_row1['id']; $user_class->create_user_login_token($to_user_id,$from_user_id,$target_id,$token,4,$utility_class,$db); $url_params = array( 'token'=>$token, 'type'=>4, // 'category'=>'tickets', // 'action'=>'view', 'id'=>$target_id, // 'notification'=>"[$ticket_id,$to_user_id]", ); $append_link = $global_system_settings['url']."token.php"."?".http_build_query($url_params); $append_link = urlencode($append_link); $append_link = $utility_class -> curl_me( "https://s.autohub.ph/?url=$append_link&format=text", array(), 'GET'); $message_will_be_sent = "\n\nNew Video: ".$video_title."\nClick to view: ".$append_link; // echo $user_row1['api_id'];exit; $bot = new Bot(['token' => $apiKey]); $bot->getClient()->sendMessage( (new \Viber\Api\Message\Text()) ->setSender($botSender) ->setReceiver($user_row1['api_id']) ->setText($message_will_be_sent) ); } } catch (Exception $e) { echo $e; }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings