telegram bot buttons change into one - php

what I am trying to achieve is that when someone clicks button for example 'done' there should be one button with 'done' text in it and if user clicks that single button - all three previous buttons should be shown again.
The text above the buttons should remain the same all the time.
All of it should be in php.
My code is:
$data = [
'text' => 'some text here'
];
$keyboard = json_encode([
"inline_keyboard" => [
[
[
"text" => "Done",
"callback_data" => "done"
],
[
"text" => "Cancel",
"callback_data" => "cancel"
],
[
"text" => "processing",
"callback_data" => "processing"
],
]
]
],true);
$url ="https://api.telegram.org/bot$token/sendMessage?".http_build_query($data). "&parse_mode=html".'&reply_markup='.$keyboard;

Related

Apple Wallet Store card expired before Expiry Date

In the application, we have a feature to download the wallet card into the Apple wallet as a contact card.
We have created this wallet contact card from the PHP code - below.
$data = [
'description' => 'MyApp',
'formatVersion' => 1,
'organizationName' => 'My app',
'passTypeIdentifier' => 'pass.test.test',
'serialNumber' => '12345678',
'teamIdentifier' => '*********',
'storeCard' => [
"headerFields" => [
[
"key" => "header-text",
"label" => "Let's connect",
"value" => "Together"
]
],
"auxiliaryFields" => [
[
"key" => "aux-text-two",
"label" => "",
"value" => ""
],
[
"key" => "aux-text-one",
"label" => "www.abc.com",
"value" => ""
]
],
"primaryFields" => [],
'secondaryFields' => [],
'backFields' => [],
],
'barcode' => [
'format' => 'PKBarcodeFormatQR',
'message' => 'https://abc.1-2-3-4-5.xyz/public/myapp/?id='.$userData->token.'',
'messageEncoding' => 'iso-8859-1',
],
"backgroundColor" => "rgb(255,255,255)",
'logoText' => '',
'relevantDate' => date('Y-m-d\TH:i:sP'),
"expirationDate" => "2030-01-01T23:00:00Z",
];
We are requesting an apple wallet card to be generated from the iOS code calling API for this - below.
if PKPassLibrary.isPassLibraryAvailable(){
if let data = try? Data(contentsOf: url){
if let pass = try? PKPass(data: data){
let passLibrary = PKPassLibrary()
if !passLibrary.containsPass(pass),
let passController = PKAddPassesViewController(pass: pass){
passController.delegate = self
self.present(passController, animated: true)
}else{
ShowAlert(message: "contact_card_already_exist".localize(), theme: .error)
}
}
}
}
As screenshots say - it’s valid till 1/1/30, PHP code we have given the expiry date as well, but still, the wallet card is gone to Expired in 2 days.
Any help is appreciated.

Push notification with pusher beam, unable to send data/payload

I am using following php sdk for generating pusher beam push notification. but there is not information provided in the sdk docs on how to send data/payload along with it. the notification is bean sent correctly but I am unable to send data: please guide me how we can send the data: it is showing hasData as false in beam console, please check:
php sdk i am using : https://github.com/pusher/push-notifications-php
my code look like this:
$pushNotification = new PushNotifications([
'instanceId' => env('BEAM_INSTANCE_ID'),
'secretKey' => env('BEAM_PRIMARY_KEY')
]);
$pushNotification->publishToInterests(
['message-notification'],
[
"apns" => [
"aps" => [
"alert" => "Message Received",
],
],
"fcm" => [
"notification" => [
'title' => 'some title',
'body' => 'some body',
'data' => 'some data', //passing data here but not working
],
],
]
);
I got it working, we can pass data in following way:
$publishResponse = $pushNotifications->publishToInterests(
["donuts"],
[
"apns" => [
"aps" => [
"alert" => "Hello!",
],
],
"fcm" => [
"notification" => [
"title" => "Hello!",
"body" => "Hello, world!",
],
"data" => [ // <==== pass data here
"name" => "adam",
"type" => "user",
],
],
]
);

How to create a command “Select a group” in a telegram bot?

I'm using Laravel 8, irazasyed/telegram-bot-sdk.
I created an inline "Select Group" button.
public function handle()
{
$inlineLayout = [
[
Keyboard::inlineButton(['text' => 'Choose a group', 'callback_data' => 'data']),
]
];
$reply_markup = Keyboard::make([
'inline_keyboard' => $inlineLayout,
'resize_keyboard' => true,
'one_time_keyboard' => true,
]);
$this->replyWithMessage(['text' => 'Click on the button to select a group.', 'reply_markup' => $reply_markup]);
}
How to hang an event on this button so that you can select a group in the chat?
It turned out that everything is simple.
It is necessary to add the url parameter:
$inlineLayout = [
[
Keyboard::inlineButton(['text' => 'Choose a group', 'callback_data' => 'data', 'url' => 'https://t.me/all2all_bot?startgroup=c']),
]
];

FCM link not working in desktop notification

We are trying to send a desktop notification calling the FCM rest api via a php service.
We call the https://fcm.googleapis.com/fcm/send service, passing the following payload:
"data" => [
"notification" => [
"title" => $content->title,
"body" => "notification body",
"icon" => url('assets/images/logo_3.png'),
],
"webpush" => [
"headers" => [
"Urgency" => "high",
],
"fcm_options" => [
"link" => url($content->url)
]
],
],
The notification is received in desktop (tested on windows 10) but when we click on the popup the link is not opened in the browser.
What are we doing wrong?
It turns out that we must use click_action field, like this:
"notification" => [
"title" => $content->title,
"body" => "body",
"icon" => "assets/icon.png",
"click_action" => "https://www.example.com",
]
Docs here:https://firebase.google.com/docs/cloud-messaging/http-server-ref

PHP based Telegram bot InlineKeyboardMarkup not working

Trying to create inline buttons for my Telegram bot. this is the request I'm sending and for some reason I don't get the buttons but only the text "Inline Keyboard"
Here is my code
$args = [
'chat_id' => $this->chat_id,
'parse_mode' => 'HTML',
'text' => 'Inline Keyboard',
'reply_markup' => [
'inline_keyboard' => [
[
[
'text' => 'Try me',
]
]
]
]
];
$send = $this->api_url . "/sendmessage?" . http_build_query($args);
file_get_contents($send);
Found the problem, You must use exactly one of the optional fields .. 'text' field is not enough

Categories