Comments (18)
I'm planning to update my API to version 2.0, now i just need to find some time (it's the hard part :D)
from telegrambotphp.
Added support for InlineKeyboard and Callback.
Next step i'll implement the inlinequery.
from telegrambotphp.
Ehi Eleirbag89 good job! Thi library is easy to understand! I just managed to send my first "spontaneous" message from php to telegram 👯
from telegrambotphp.
Aongratulations for your job.
An example of how to use InlineKeyboard ?
I can not use buildKeyBoardButton whit $request_location
from telegrambotphp.
For your problem, try
$option = array( array($telegram->buildInlineKeyboardButton("Test location", false, true)), array($telegram->buildInlineKeyboardButton("Test contact", true, false)) );
// Create a permanent custom keyboard
$keyb = $telegram->buildKeyBoard($option, $onetime=false);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "Welcome to Bot !");
$telegram->sendMessage($content);
If you want to use an InlineKeyboard:
$option = array( array( $telegram->buildInlineKeyboardButton("Test", $url="http://google.it"), $telegram->buildInlineKeyboardButton($text="Test2","","Callback","") ) );
$keyb = $telegram->buildInlineKeyBoard($option);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "Welcome to Bot !");
$telegram->sendMessage($content);
I didn't test it but they should work
from telegrambotphp.
I have a problem with your code, with normal keyboard works well:
$option = array(array($telegram->buildInlineKeyboardButton("Test location", false, true)), //not work
array($telegram->buildKeyboardButton("Test location", false, true)) //this work
);
// Create a permanent custom keyboard
$keyb = $telegram->buildKeyBoard($option, $onetime=true);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "Welcome to Bot !");
$telegram->sendMessage($content);
but I can not run with the InlineKeyboard
$option = array( array( $telegram->buildInlineKeyboardButton("Test", $url="http://google.it"), //work
$telegram->buildInlineKeyboardButton($text="Test2","","Callback",""),//work
$telegram->buildKeyboardButton("Test contact", true, false), //not work
$telegram->buildKeyboardButton("Test location", false, true) //not work
) );
// Create a permanent custom keyboard
$keyb = $telegram->buildInlineKeyBoard($option);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "Welcome to Bot !");
$telegram->sendMessage($content);
i can ask the position with an the InlineKeyboard?
thank you
Grazie.
from telegrambotphp.
You cannot mix KeyboardButton and InlineKeyboardButton.
Accordingly to the API https://core.telegram.org/bots/api#inlinekeyboardbutton the InlineKeyboardButton doesn't have a field to send automatically the contact or the position.
It's dumb but there is nothing you can do, you can only try to ask the Telegram Team to add this feature for the InlinekeyboardButton in the future, or just use a regular Keyboard.
from telegrambotphp.
I need to update the examples, but i really don't have time.
I just paste an example here:
if ($callback_query !== null && $callback_query != "") {
$reply = "Callback data value".$telegram->Callback_Data();
$content = array('chat_id' => $telegram->Callback_ChatID(), 'text' => $reply);
$telegram->sendMessage($content);
$content = array('callback_query_id' => $telegram->Callback_ID(), 'text' => $reply, 'show_alert' => true);
$telegram->answerCallbackQuery($content);
}
PS
I'm sorry, i deleted the previous comment by accident:
that's perfect
please send an example of answer to callback query
thanks
from telegrambotphp.
@Eleirbag89 Your code works nice!
And you already answer to callback query :)
from telegrambotphp.
The code does not return any value
result ==> Callback data valueCallback
from telegrambotphp.
@persin can you explain your problem?
from telegrambotphp.
As a result the following code to the user's phone number but does not return a value
(
Please example, to obtain and display the user's contact number)
include("Telegram.php");
$telegram = new Telegram($bot_id);
$result = $telegram->getData();
$chat_id = $result["message"] ["chat"]["id"];
$option = array( array( $telegram->buildInlineKeyboardButton("Test", $url="http://google.it"), //work
$telegram->buildInlineKeyboardButton($text="Test2","","Callback",""),//work
$telegram->buildKeyboardButton("Test contact", true, false), //not work
$telegram->buildKeyboardButton("Test location", false, true) //not work
) );
$keyb = $telegram->buildInlineKeyBoard($option);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "Welcome to Bot !");
$telegram->sendMessage($content);
$reply = "Callback data value".$telegram->Callback_Data();
$content = array('chat_id' => $telegram->Callback_ChatID(), 'text' => $reply);
$telegram->sendMessage($content);
from telegrambotphp.
You cannot mix KeyboardButton and InlineKeyboardButton.
See my 16 Apr comment on this same issue.
from telegrambotphp.
news for InlineQuery ?
from telegrambotphp.
No there isn't any news.
The staggering amount of InlineQueryResult it's really a letdown.
I should do 19 functions and test them, right now i don't have the time and i don't feel like doing it (also i think the code will become messy).
Anyone is welcome to do a pull request :D
from telegrambotphp.
ok. here the code that i used in @museimibactbot only for 2 function of
inline query.
in Telegram.php:
public function InlineQueryResultArticle($id, $title,
$input_message_content,$thumb_url = "", $reply_markup,$url = "", $hide_url
= false, $description = "", $thumb_width , $thumb_height)
{
$type = 'article';
$params = compact('type', 'id', 'title', 'input_message_content',
'thumb_url','reply_markup','url', 'hide_url',
'description','thumb_width','thumb_height');
return $params;
}
public function InlineQueryResultLocation($id, $latitude,$longitude,$title )
{
$type = 'location';
$params = compact('type', 'id', 'latitude','longitude','title');
return $params;
}
public function answerInlineQuery(array $content) {
return $this->endpoint("answerInlineQuery",$content);
}
in bot.php :
$id=$inline_query['id'];
$lat=$inline_query["location"]['latitude'];
$lon=$inline_query["location"]['longitude'];
$id3 = $telegram->InlineQueryResultLocation($id."/0", $lat,$lon, "Nessun
Museo in questo luogo\nNo Museum around you in this place");
$res= array($id3);
$content=array('inline_query_id'=>$inline_query['id'],'results'
=>json_encode($res));
$telegram->answerInlineQuery($content);
2016-06-18 18:05 GMT+02:00 Gabriele Grillo [email protected]:
No there isn't any news.
The staggering amount of InlineQueryResult it's really a letdown.
I sould do 19 functions and test it, right now i don't have the time and i
don't feel like doing it.
Anyone is welcome to do a pull request :D—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#9 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AFzRuoBiazOZg9rjNbvVFNfc-t3yg3g7ks5qNBdVgaJpZM4IFg4g
.
from telegrambotphp.
didnt you update to new api 2.0 ?
from telegrambotphp.
The InlineQuery feature is still missing. You can do it manually but there are no built-in methods. All the other features (like callback query and inlinekeyboard) are done
from telegrambotphp.
Related Issues (20)
- Telegram::getChatMembersCount() method
- [BUG]
- Hi~~ @Eleirbag89 pls delete this issue,thanks!
- Web Apps HOT 8
- UpdateCount[BUG] HOT 2
- payment function HOT 1
- you have any video for this bot like tutorial ? HOT 1
- How to make wait for answer HOT 2
- Can you create .phar file for this project HOT 9
- [BUG]
- ErrorException Undefined array key "message" when using funtion UserID() HOT 3
- Formatting options HOT 3
- sendMediaGroup not working! HOT 1
- How to get user_id of the message of a user I reply to? HOT 1
- Add API Support for up to API 6.9 (22.09.2023) HOT 1
- Please Add Forward From Username HOT 1
- My button not a have actions
- how to send sticker HOT 2
- Failed to connect to api.telegram.org port 443 after 21043 ms: Timed out HOT 2
- local-bot-api-server HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegrambotphp.