Telegram Bot inlinefeedback不会返回任何更新

时间:2018-03-11 17:26:51

标签: php telegram telegram-bot

我在Botfather中启用/ setinlinefeedback(100%用于测试),我的answerInlineQuery显示正确的结果,没有错误{“ok”:true,“result”:true} ...但是当点击其中一个结果时返回no更新,当我将更新发送到聊天时,更新返回

{ “UPDATE_ID”:14516733,    “消息”: “从{” ID 1857,:{ “MESSAGE_ID” “:96000969,” is_bot “:假”,如first_name “:” Mostafa的”, “姓氏”: “Emrani”, “用户名”: “Mostafa_MRNI”, “LANGUAGE_CODE”: “EN-US”}, “聊天”:{ “ID”:96000969, “FIRST_NAME”: “穆斯塔法”, “姓氏”: “Emrani”, “用户名”: “Mostafa_MRNI”, “类型”: “private”},“date”:1520788397,“text”:“您的产品:”}}

更新if (isset($update->chosen_inline_result->result_id))返回false。

我的answerInlineQuery函数:

if (isset($update->inline_query)) {

        $inlineQuery = $update->inline_query;
        $queryId = $inlineQuery->id;
        $userId = $inlineQuery->from->id;
        $Chatid = $this->model->getChatIdformUser($userId);
        $queryText = $inlineQuery->query;

        //$this->model->sendMessage($Chatid, $queryId . '-' . $userId . '-' . $Chatid . '-' . json_encode($inlineQuery, JSON_UNESCAPED_UNICODE));

        if ($queryText == '#invoice') {
            $resu = $this->model->answerInlineQuery($queryId, $this->queryResultsInvoice($Chatid), 0, true);
        } else {
            $resu = $this->model->answerInlineQuery($queryId, $this->queryResults($queryText), 0, false);
        }
        //$this->model->sendMessage($Chatid, json_encode($resu));
    }

function answerInlineQuery($inline_query_id, $results, $cache_time , $is_personal)
{

    $url = 'https://api.telegram.org/bot' . BOT_API_KEY . '/answerInlineQuery';

    $post = array("inline_query_id" => $inline_query_id, "results" => json_encode($results), "cache_time" => $cache_time, "is_personal" => $is_personal);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 500);

    $check = curl_exec($ch);
    curl_close($ch);
    //$this->sendMessage($chatid,$check);
    return $check;
}

   function queryResults($qryText)
{
    $res = $this->model->inlineSearch($qryText);
    $result = array();
    for ($x = 1; $x <= sizeof($res); $x++) {
        $result1 = array('type' => 'article', 'id' => strval($res[$x - 1]['prod_code']), 'title' => $res[$x - 1]['prod_name'], 'input_message_content' => array('message_text' => 'Your Product:'), 'description' => $res[$x - 1]['prod_price'] . ' $ ');
        array_push($result, $result1);
    }
    return $result;
}

function queryResultsInvoice($Chatid)
{
    $res = $this->model->getProductInOrder($Chatid);
    $result = array();
    for ($x = 1; $x <= sizeof($res); $x++) {
        $res_prodCount = $this->model->getCountProd($Chatid, $res[$x - 1]['prod_id']);
        $desc = '';
        if ($res_prodCount != 0) {
            $desc = '-- In your order ' . $res_prodCount . 'has available.';
        }
        $result1 = array('type' => 'article', 'id' => strval($res[$x - 1]['prod_code']), 'title' => $res[$x - 1]['prod_name'], 'input_message_content' => array('message_text' => 'Your Product:'), 'description' => $res[$x - 1]['prod_price'] . ' $ ' . $desc);
        array_push($result, $result1);
    }
    return $result;
}

当我getWebhookInfo没有返回错误时...请帮助我...我在这个问题上花了5天时间并且不知道解决它...

0 个答案:

没有答案