GithubHelp home page GithubHelp logo

Comments (18)

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024 2

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.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024 2

Added support for InlineKeyboard and Callback.
Next step i'll implement the inlinequery.

from telegrambotphp.

matrix866 avatar matrix866 commented on September 28, 2024 1

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.

FrancescoBOT avatar FrancescoBOT commented on September 28, 2024

Aongratulations for your job.
An example of how to use InlineKeyboard ?
I can not use buildKeyBoardButton whit $request_location

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

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.

FrancescoBOT avatar FrancescoBOT commented on September 28, 2024

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.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

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.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

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.

xpyctum avatar xpyctum commented on September 28, 2024

@Eleirbag89 Your code works nice!
And you already answer to callback query :)

from telegrambotphp.

persin avatar persin commented on September 28, 2024

The code does not return any value
result ==> Callback data valueCallback

from telegrambotphp.

xpyctum avatar xpyctum commented on September 28, 2024

@persin can you explain your problem?

from telegrambotphp.

persin avatar persin commented on September 28, 2024

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.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

You cannot mix KeyboardButton and InlineKeyboardButton.
See my 16 Apr comment on this same issue.

from telegrambotphp.

piersoft avatar piersoft commented on September 28, 2024

news for InlineQuery ?

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

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.

piersoft avatar piersoft commented on September 28, 2024

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.

 avatar commented on September 28, 2024

didnt you update to new api 2.0 ?

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.