Telegram
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Telegram
exist some method to send sms or small message on telegram from fivewin ?
Can see any easy sample ?
for telegram I found ( some one can help me )
https://core.telegram.org/mtproto
https://core.telegram.org/api
https://telegram.org/apps#source-code
there is also a lib to use with c++
https://core.telegram.org/tdlib
Can see any easy sample ?
for telegram I found ( some one can help me )
https://core.telegram.org/mtproto
https://core.telegram.org/api
https://telegram.org/apps#source-code
there is also a lib to use with c++
https://core.telegram.org/tdlib
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: Telegram
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Telegram
I tried it only not found token and chatid
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
-
- Posts: 69
- Joined: Wed Nov 19, 2014 1:04 pm
- Contact:
Re: Telegram
Dear Mr.SilvioSilvio.Falconi wrote:I tried it only not found token and chatid
check the following link for how to get telegram token
https://www.siteguarding.com/en/how-to- ... -api-token
http://forums.fivetechsupport.com/viewt ... 56&start=0
Regards
Yunus
Dagia Yunus.
Rajkot, India
FWH 17.04
Rajkot, India
FWH 17.04
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Telegram
Yunus,
I create mybot and I have token
now it want chat_id where i take this ?
then I compiled the prg into http://forums.fivetechsupport.com/viewt ... =0#p194671
it is compiled and not happen nothing
it not open any htpp
I have this ( on word mytoken I copied my token)
and then I not understtod how send a msg
as you can see here I Instal telegram for window and I open it
then I compiled your test and not happened nothig
I create mybot and I have token
now it want chat_id where i take this ?
then I compiled the prg into http://forums.fivetechsupport.com/viewt ... =0#p194671
it is compiled and not happen nothing
it not open any htpp
I have this ( on word mytoken I copied my token)
and then I not understtod how send a msg
Code: Select all
#include "fivewin.ch"
function Main()
local odoc := CreateObject( "MSXML2.DOMDocument" )
local ohttp := CreateObject( "MSXML2.XMLHTTP" )
local cTOKEN:= "mytoken"
local URL:="https://api.telegram.org/bot"+cTOKEN+"/getUpdates"
ohttp:Open( "POST" ,URL, .F. )
oHttp:SetRequestHeader("Accept" ,"application/xml")
oHttp:SetRequestHeader("Content-Type","application/json")
oDoc:async:=.f.
oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
oHttp:Send(oDoc:xml)
cText:=Alltrim(oHttp:responseText)
cText=strtran(cText,'{"ok":true,"result":[','')
cText=alltrim(cTExt)
ar:=HB_ATOKENS( cTEXT, '{"update_id":' ) // split json string to array
for i=2 to len(ar)
x:=ar[i]
nUpdateId:=GetUpdateId(x)
?nUpdateId, "Message_id",ExtractValue(x,"message_id"),"From_Id",ExtractValue(x,'from":{"id'),"Chat_Id",ExtractValue(x,'"chat":{"id')
fName:=ExtractValue(x,"first_name")
fname:=strTran(fname,'}','')
?fname
?GetMsg(x)
next i
return nil
function ExtractValue(x,srchValue)
return SubStr( x, nAt := At( srchValue, x ) + Len( srchValue )+2, At( ",", SubStr( x, nAt ))-1)
//?SubStr( x, nAt := At( "message_id", x ) + Len( "message_id" )+2, At( ",", SubStr( x, nAt + Len( "message_id" ) )) -1 )
function GetUpdateId(x)
substr(x,1,at(",",x)-1)
function Getmsg(x)
cMsg:=RIGHT(x,LEN(x) - RAT(":", x) - 1)
cMsG:=substr(cMsg,1,rat('"',cMsg)-1)
return cMsg
function sendmsg(cChatId,cMsg) // CHAT_ID how to get chat_id please look my first post
local odoc := CreateObject( "MSXML2.DOMDocument" )
local ohttp := CreateObject( "MSXML2.XMLHTTP" )
local cTOKEN:= "mytoken"
ohttp:Open( "POST" ,"https://api.telegram.org/bot"+cTOKEN+"/sendMessage?text="+cMsg+"&chat_id="+cChatId+'"', .F. )
ohttp:SetRequestHeader( "Accept" , "application/xml")
ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
oDoc:async := .f.
oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
ohttp:Send(oDoc:xml)
oDoc:=Nil
return nil
as you can see here I Instal telegram for window and I open it
then I compiled your test and not happened nothig
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: Telegram
João Santos - São Paulo - Brasil
-
- Posts: 69
- Joined: Wed Nov 19, 2014 1:04 pm
- Contact:
Re: Telegram
to retrieve chat id first you have to send some text msg to your bot using telegramSilvio.Falconi wrote:Yunus,
I create mybot and I have token
now it want chat_id where i take this ?
then I compiled the prg into http://forums.fivetechsupport.com/viewt ... =0#p194671
it is compiled and not happen nothing
it not open any htpp
I have this ( on word mytoken I copied my token)
and then I not understtod how send a msg
Code: Select all
#include "fivewin.ch" function Main() local odoc := CreateObject( "MSXML2.DOMDocument" ) local ohttp := CreateObject( "MSXML2.XMLHTTP" ) local cTOKEN:= "mytoken" local URL:="https://api.telegram.org/bot"+cTOKEN+"/getUpdates" ohttp:Open( "POST" ,URL, .F. ) oHttp:SetRequestHeader("Accept" ,"application/xml") oHttp:SetRequestHeader("Content-Type","application/json") oDoc:async:=.f. oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>') oHttp:Send(oDoc:xml) cText:=Alltrim(oHttp:responseText) cText=strtran(cText,'{"ok":true,"result":[','') cText=alltrim(cTExt) ar:=HB_ATOKENS( cTEXT, '{"update_id":' ) // split json string to array for i=2 to len(ar) x:=ar[i] nUpdateId:=GetUpdateId(x) ?nUpdateId, "Message_id",ExtractValue(x,"message_id"),"From_Id",ExtractValue(x,'from":{"id'),"Chat_Id",ExtractValue(x,'"chat":{"id') [color=#FF0000]When someone send msg to your telegram bot than you cn get the chat id.[/color] fName:=ExtractValue(x,"first_name") fname:=strTran(fname,'}','') ?fname ?GetMsg(x) next i return nil function ExtractValue(x,srchValue) return SubStr( x, nAt := At( srchValue, x ) + Len( srchValue )+2, At( ",", SubStr( x, nAt ))-1) //?SubStr( x, nAt := At( "message_id", x ) + Len( "message_id" )+2, At( ",", SubStr( x, nAt + Len( "message_id" ) )) -1 ) function GetUpdateId(x) substr(x,1,at(",",x)-1) function Getmsg(x) cMsg:=RIGHT(x,LEN(x) - RAT(":", x) - 1) cMsG:=substr(cMsg,1,rat('"',cMsg)-1) return cMsg function sendmsg(cChatId,cMsg) // CHAT_ID how to get chat_id please look my first post local odoc := CreateObject( "MSXML2.DOMDocument" ) local ohttp := CreateObject( "MSXML2.XMLHTTP" ) local cTOKEN:= "mytoken" ohttp:Open( "POST" ,"https://api.telegram.org/bot"+cTOKEN+"/sendMessage?text="+cMsg+"&chat_id="+cChatId+'"', .F. ) ohttp:SetRequestHeader( "Accept" , "application/xml") ohttp:SetRequestHeader( "Content-Type" ,"application/json" ) oDoc:async := .f. oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>') ohttp:Send(oDoc:xml) oDoc:=Nil return nil
as you can see here I Instal telegram for window and I open it
then I compiled your test and not happened nothig
(after sending text msg using telegram in your browser type
https://api.telegram.org/botcTOKEN/getUpdates )
http://forums.fivetechsupport.com/viewt ... =0#p194671
for further details you may contact me on dagiayuns at gmail.com
Dagia Yunus.
Rajkot, India
FWH 17.04
Rajkot, India
FWH 17.04
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Telegram
yunus,
your email no exist
send me a message at silvio[dot]falconi[at]gmail[dot]com thanks
your email no exist
send me a message at silvio[dot]falconi[at]gmail[dot]com thanks
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Telegram
Dear my Friend,
I wish understood it telegram can be usefull for my work
I work at school and I have an application where I need to send a message to some teachers
type " 5TC 3ora Rec Bitti "
Well I say you what I made
I Installed telegram on windows and I have also the portable version
I put the portable version on c:\work\errori\Telegram\Telegram
At installation it ask me a number of my phone and a verify number
then I set on setup to luch telegram at init when the system ( pc) is open
your test compiled is on c:\work\errori\telegram (test.exe)
you sad I need ctoken and chat id
On telegram I open botfather and I create a new bot sample @sost_bot
then I ask the token and it gave me the token and I copied on your test
then I link to Falcongate and I write /get_my_id and I have the id( number)
I insert token and id on your test
cToken := ""
cChat_id := ""
ctoken from botfather
cChat_id from falcongate
I run your test and it ask me a message and when I click to button "Enviar"
it return this error
404 not found
I tried with
LOCAL cToken := "", cChat_id := "@sost_bot"
it return - 404 error bad request
where I wrong ?
Questions
To send a message to all my teacher from fwh what I need ?
I need the number of phones or the his Id ?
if i need the id, How I can make to Know the number of id of each teacher ?
I hope your help
Best Regards
I wish understood it telegram can be usefull for my work
I work at school and I have an application where I need to send a message to some teachers
type " 5TC 3ora Rec Bitti "
Well I say you what I made
I Installed telegram on windows and I have also the portable version
I put the portable version on c:\work\errori\Telegram\Telegram
At installation it ask me a number of my phone and a verify number
then I set on setup to luch telegram at init when the system ( pc) is open
your test compiled is on c:\work\errori\telegram (test.exe)
you sad I need ctoken and chat id
On telegram I open botfather and I create a new bot sample @sost_bot
then I ask the token and it gave me the token and I copied on your test
then I link to Falcongate and I write /get_my_id and I have the id( number)
I insert token and id on your test
cToken := ""
cChat_id := ""
ctoken from botfather
cChat_id from falcongate
I run your test and it ask me a message and when I click to button "Enviar"
it return this error
404 not found
I tried with
LOCAL cToken := "", cChat_id := "@sost_bot"
it return - 404 error bad request
where I wrong ?
Questions
To send a message to all my teacher from fwh what I need ?
I need the number of phones or the his Id ?
if i need the id, How I can make to Know the number of id of each teacher ?
I hope your help
Best Regards
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Telegram
Now I create a new bot FROM BOTFATHER and take the token
then I take my id from falcongate with /get-my_id
I insert the token and chat_id into test.prg (fwh)
When I sent message on this bot the test make this message
and then insert the message on bot
It run from fwh but I have some questions
1. I can create a group and link to bot and insert all techers into but each teachers read the message I sent to bot - no good
2. I wish send the message only directly to each teacher no pubblic
how I can resolve ?
then I take my id from falcongate with /get-my_id
I insert the token and chat_id into test.prg (fwh)
When I sent message on this bot the test make this message
and then insert the message on bot
It run from fwh but I have some questions
1. I can create a group and link to bot and insert all techers into but each teachers read the message I sent to bot - no good
2. I wish send the message only directly to each teacher no pubblic
how I can resolve ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Telegram
I resolved!
the problem was it cannot be a GET but a POST
It run with personal chatid and also with Group
I need to Know if I can send message to one teacher and to all teacher ( are in a Group)
the problem was I not Know the Id of all teacher and the mode more easy was that to send message to a Group where are all teachers
the group can be normal group where all member are administrators and supergroup where you decide who is the administrator and you decide who can talk
all member listen
the problem was it cannot be a GET but a POST
It run with personal chatid and also with Group
I need to Know if I can send message to one teacher and to all teacher ( are in a Group)
the problem was I not Know the Id of all teacher and the mode more easy was that to send message to a Group where are all teachers
the group can be normal group where all member are administrators and supergroup where you decide who is the administrator and you decide who can talk
all member listen
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC