Android Question Set HTTP Request with OkHttpUtils2

changiz

New Member
Hi, How do porting this pyhon code to b4a(python code as below)

Python:
import requests
url = ("https://api.telegram.org/bot1312461372:AAEfxqjSM_P6N_ljxxxUPSOVMLcEi005lE/sendmessage?chat_id=8xxx25988&text=Hello")
payload = {
    "UrlBox": url,
    "AgentList": "Mozilla Firefox",
    "VersionsList": "HTTP/1.1",
    "MethodList": "GET"
}
req = requests.post(
    "https://www.httpdebugger.com/Tools/ViewHttpHeaders.aspx", payload)
print(req)

my ported b4a code is:
B4X:
dim Url as string = "https://api.telegram.org/bot1312461372:AAEfxqjSM_P6N_ljxxxUPSOVMLcEi005lE/sendmessage?chat_id=8xxx25988&text=Hello"
dim hj as httpjob
hj.initialize
hj.poststring("https://www.httpdebugger.com/Tools/ViewHttpHeaders.aspx",$"UrlBox=${url}&AgentList=${"Mozilla Firefox"}&VersionList=${"HTTP/1.1"}&MethodList=GET"$)

it is not work correctly, what is wrong?
Set HTTP Request Header with OkHttpUtils2
 

changiz

New Member
woow, Erel;)
telegram api is blocked for me, Instead of using VPN for breaking, I want to use the "https://www.httpdebugger.com/Tools/ViewHttpHeaders.aspx" site to send my request to telegram server for use telegram API bot without VPN, By telegram bot token and telegram account id we can send a text, for example i want send hello which as below:
"https://api.telegram.org/bot1312461...05lE/sendmessage?user_id=8xxx25988&text=Hello"
this link send hello by bot to user by id: 8xxx25988
this link do not open for me without vpn, so i use site: "https://www.httpdebugger.com/Tools/ViewHttpHeaders.aspx" to send my request without vpn, but it is do not work(without error) for send hello,
 
Upvote 0
Top