Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $item_menu_query = $db->select(true,"name","menu","name_menu='$text'");
- $text = "";
- for ($menucount=0; $menucount < 1; $menucount++) {
- $text .= $item_menu_query[$menucount]['name']." &,& ";
- }
- $text = str_replace('"',"",$text);
- $params['keyboard'] = BtnBuild($text, $btn_lvl = 1, $params=[]);
- $params['peer_id'] = 137534777;
- Send($params, true);
- function Send($params=[],$debug = false) {
- $token = 'токен';
- if ($params['keyboard'] == NULL) {
- $request_params = array(
- 'message' => $params['answer_text'],
- 'peer_id' => $params['peer_id'],
- 'access_token' => $token,
- 'v' => '5.92',
- 'random_id' => rand(0,1000000),
- );
- }else{
- $request_params = array(
- 'message' => $params['answer_text'],
- 'peer_id' => $params['peer_id'],
- 'access_token' => $token,
- 'v' => '5.92',
- 'keyboard' => json_encode($params['keyboard'], JSON_UNESCAPED_UNICODE),
- 'random_id' => rand(0,1000000),
- );
- print_r($request_params);
- }
- $get_params = http_build_query($request_params);
- if ($debug == true) {
- file_put_contents('bot.txt','https://api.vk.com/method/messages.send?'. $get_params);
- }
- file_get_contents('https://api.vk.com/method/messages.send?'. $get_params, FILE_TEXT);
- }
- function BtnBuild($btn_text, $btn_lvl = 2, $params=[]) {
- $btns_text_array = explode("&,&", $btn_text);
- for ($i=0;$i<count($btns_text_array);$i++) {
- switch($btn_lvl) {
- case "1":
- $btns[$i]=[['action' =>['type' => 'text','label' => $btns_text_array[$i],],'color' => 'primary']];
- break;
- case "2":
- $btns[$i]=['action' =>['type' => 'text','label' => $btns_text_array[$i],],'color' => 'primary'];
- break;
- }
- }
- switch($btn_lvl) {
- case "1":
- $keyboard =
- array(
- 'one_time' => true,
- 'buttons' =>$btns
- );
- break;
- case "2":
- $keyboard =
- array(
- 'one_time' => true,
- 'buttons' =>
- array(
- $btns
- ),
- );
- break;
- }
- return $keyboard;
- }
Add Comment
Please, Sign In to add comment