Проблема с HTTP запросом

Manuel Leon

Известный
Автор темы
267
165
Версия MoonLoader
.026-beta
Вместо получения JSON, возращается код страницы:
Должно
Код:
{"ok":true,"result":{"message_id":23,"from":{"id":id,"is_bot":true,"first_name":"HN_bot","username":"HNSamp_Bot"},"chat":{"id":id,"first_name":"name","last_name":"name","username":"username","type":"private"},"date":date,"text":"text"}}

функция
lua:
function getLastUpdate() -- тут мы получаем последний ID сообщения, если же у вас в коде будет настройка токена и chat_id, вызовите эту функцию для того чтоб получить последнее сообщение
    async_http_request('https://api.telegram.org/bot'..token..'/getUpdates?chat_id='..chat_id..'&offset=-1','',function(result)
        if result then
            local proc_table = decodeJson(result)
            if proc_table.ok then
                if #proc_table.result > 0 then
                    local res_table = proc_table.result[1]
                    if res_table then
                        updateid = res_table.update_id
                    end
                else
                    updateid = 1 -- тут зададим значение 1, если таблица будет пустая
                end
            end
        end
    end)
end
Возвращается это:​
html:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.2.1</center>
</body>
</html>
 

kin4stat

mq-team
Всефорумный модератор
2,731
4,692
Вместо получения JSON, возращается код страницы:
Должно
Код:
{"ok":true,"result":{"message_id":23,"from":{"id":id,"is_bot":true,"first_name":"HN_bot","username":"HNSamp_Bot"},"chat":{"id":id,"first_name":"name","last_name":"name","username":"username","type":"private"},"date":date,"text":"text"}}

функция
lua:
function getLastUpdate() -- тут мы получаем последний ID сообщения, если же у вас в коде будет настройка токена и chat_id, вызовите эту функцию для того чтоб получить последнее сообщение
    async_http_request('https://api.telegram.org/bot'..token..'/getUpdates?chat_id='..chat_id..'&offset=-1','',function(result)
        if result then
            local proc_table = decodeJson(result)
            if proc_table.ok then
                if #proc_table.result > 0 then
                    local res_table = proc_table.result[1]
                    if res_table then
                        updateid = res_table.update_id
                    end
                else
                    updateid = 1 -- тут зададим значение 1, если таблица будет пустая
                end
            end
        end
    end)
end
Возвращается это:​
html:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.2.1</center>
</body>
</html>
Прочитай что тебе возвращается