Telegram Bot: Custom Keyboard to send Codes - php

As i checked here the KeyboardButton object in telegram have nothing such as tag or data field. I had this implementation for keyboard of my bot:
$keyboardArray = array('Hello', 'Hi');
apiRequestJson("sendMessage", array('chat_id' => $chat_id, "text" => 'Hello', 'reply_markup' => array(
'keyboard' => array($keyboardArray),
'one_time_keyboard' => true,
'resize_keyboard' => true)));
Currently pressing a keyboard button, send the label of button to my bot.
I want to know are there any options for telegram keyboard, which it can send special message to bot other than label of keyboard button? For example it send 100 when I press hello, 200 when I press Hi button.

Nope, it is not possible, these Keyboards can only send their own label. What would be possible are InlineKeyboards (see this). There you can specify callback_data, which is given to your server when the key is pressed. You could also specify a URL to be opened on button click. See documentation for InlineKeyboardButton here.

Related

How we can send image and icon by using Firebase cloud messaging(fcm) for push notification in android

I want to send an image and icon in my Push notification from my Serverside(php) to my app.
I have searched on Google but was unable to get the proper result.
I get FCM PHP Code. I use these code for sending notification but when I use "image and icon" parameter image not receive in notification.
In GCM it's easy to send icon and image in Push notification
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array(
"title" => "SamplePush Application",
"style" => "inbox"; //picture/inbox,
"message" => "I am just testing Push notification",
"notId" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"summaryText" => "Venha provar os nossos Gins",
"image" => "http://gintonico.com/content/uploads/2015/03/fontenova.jpg",
"picture" => "http://media5.letsbonus.com/products/285000/285006/14014409744462-0-1700x690.jpg"
) ,
If anyone can send image and icon in notification using FCM please help me.
Simply, I change my plugin and use phonegap-plugin-push v2.0.x and it work fine. Now I am able to send big image in the notification.
Notification image must be PNG image. Replace jpg image with png image.

Telegram Bot API - ForceReply with Custom Keyboard

From reading the Telegram Bot API i understand it is only possible to either have a ForceReply or Custom Keyboard. Not both at the same time.
But how can i know if the user's input from Custom Keybord is a reply to the bot's message?
I have this code (PHP) running:
apiRequest ( "sendMessage", array (
"text" => "Choose option",
'chat_id' => $chat_id,
'reply_markup' => $keyboardOptions
)
);
resulting in this:
I know i can get the content of clicked button, but the field "reply_to_message" is missing (because it's no reply).
How is PollBot pulling this off? Looks like a ForceReply together with Custom Keybord?

ALL GCM parameters?

i´ve written a "pushserver" for my app via PHP.
The push notifications i´ve sent via PHP are all received on the device, so far.
But, i can just send/set the "message" and "title", see:
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array(
'message' => $message,
'title' => 'My App',
'vibrate' => 1,
'sound' => 1,
'icon' => "http://example.com/image.jpg",
"style" => "inbox"
),
);
"icon" and "style" are not working (vibrate and sound not tested, yet).
Every link for the parameters i´ve found is broken or kind of "you need to do object.setSomething() in JAVA.
Is there a list anywhere where i can see ALL parameters, which i can send to GCM? No matter, what language i use?
Cheers,
Chris
couple of things need to keep in mind while all the data which you sending from server end
Is there a list anywhere where i can see ALL parameters,
exp :- you can send as many parameters as you want but offcourse there is limitation but not key specific just like you can use "textmessage" instead of "message" but make sure to retrieve the value from same key which you are assigning from server end
1) please make sure that you are getting all the data in gcmintentservice class try to print the log of all intent data.
please remember that this is just a string data it is not going to download the image for you. you have to download using volley library or any suitable library

Post in the wall of a Facebook user

My question is very simple and has been answered lots of times in Stackoverflow but in order to the changing of the Facebook API I want to make certain if a user who is using my app can post to their wall a message generated automatically by the app.
If the user is reading in my app a comment he/she likes, I want he/she can post to their wall a message like "I've been reading a very interesting comment about..." and I would like that tis text appears automatically in the window where Facebook requests permission to the user to post in their wall.
I've tried the JS API with "feed" method but the text in the field message is ignored. I'm going to try with PHP API but I think the result will be the same.
Thanks in advance!!
JavaScript SDK
You can send the following values using the JavaScript SDK:
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
(code and image taken from the docs)
I described, what field is what text in the popup.
If not provided, name, image, caption and description are derived from the webpage, given in the link.
You cannot include a default message in the JS popup.
PHP SDK
If you are using the PHP SDK, you can however include a message.
Code example:
try {
$facebook->api(
"/{$facebookId}/feed",
"POST",
array(
// this is the important part
'message' => "This is your message!",
'link' => $yourLink,
'name' => "This is your name",
'caption' => '..',
'description' => '...',
'type' => 'link',
'application' => array(
'name' => 'Name of your app',
'id' => $idOfYourApp
)
)
);
}
catch (\FacebookApiException $exception)
{
// ...
}
the "message" field in feed no longer works. You have to use "description" or "caption"
This is because Facebook mentioned something along the lines of "A user should be able to say what they want about content on the internet".

Using graph API and creating a link on the event page

I must be missing something really obvious.
I have created successfully an Event with the graph API
I now want to put a link on the event page
When i use the code below, it creates a message but not a link. So please someone what am i missing. I do get a linkid back as well as you can see the message on the page.
So this is the pretty simple code.
$fb = new Facebook(array(
'appId' => FB_APP_ID,
'secret' => FB_APP_SECRET,
'cookie' => true,
'fileUpload' => true
));
$fb->setAccessToken($_SESSION[ $eid.'_FB_USER_ACCESSCODE' ]);
$data = array( 'access_token' => $_SESSION[ $eid.'_FB_USER_ACCESSCODE' ],
'link' => 'http://www.thedomain.com',
'message' => "To purchase your tickets"
);
$result = $fb->api($newFBEventId."/feed","post",$data);
Thanks
This is a Bug and its reported and marked as confidential
With the below text and its also contain security hole
bug report link
Below is my bug report text.
Other details on this report are shown to Facebook employees only
I recently attempted to post on an event's wall using the Graph API, but only the message is posted; Everything else is not showing. e.g.
Link
Picture
etc
There is one more big thing that the post doesn't show; That this post is post "via a Facebook app"
Note: posting on a page or user wall worked and also normal messages posted on an event 's wall.
The most important thing is when the post is shown on the event's wall "it does not show that its posted by a Facebook Application".
This is very dangerous; For example I can make an application and post nonsense on a user's event wall. People will think that this is posted by the user.
Thanks

Categories