Search code examples
telegramtelegram-botphp-telegram-bot

Inline bot doesn't show anything


I try to setup an inline bot that send just 1 picture for user query.

All seems to be working, but bot doesn't show any results in app, not even switch_pm_text I give to him. I think I somehow messed with results array? I parse all the incoming stuff from Telegram correctly, i.e. I see query ID and query itself, an image searches all right, but nothing get sent to Telegram as an answer...

Here is my code:

$search_result = json_decode(file_get_contents('https://www.googleapis.com/customsearch/v1?key=blahblah&q='.urlencode($queue).'&num=1&searchType=image&safe=off&fileType=jpg'), TRUE);  
$image = $search_result['items'][0]['link'];
$thumb = $search_result['items'][0]['image']['thumbnailLink'];

$image_to_send = array(array(
    'type' => 'photo',
    'id' => '1',
    'photo_url' => $image,
    'thumb_url' => $thumb
));

file_get_contents($GLOBALS['api'].'/answerInlineQuery?inline_query_id='.$queryid.'&results='.json_encode($image_to_send).'&switch_pm_text=БОТ');

Solution

  • In my case it was switch_pm_text parameter which somehow blocked an API request.