Answer the question
In order to leave comments, you need to log in
Fetch, how to write a script, having data from the browser?
There is a provider with the site provider.ltd
Turning on / off services is done by pressing a button on a specialized page.
Help parse the sent data and convert it to mikrotik's fetch to automate this process.
Here's what happens in the browser when a button is clicked
Summary
URL: https://provider.ltd/path-to-script.php
Status: 200 OK
Source: Network
Address: 1.1.1.1:443
Request
POST /path-to-script.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Origin: https://provider.ltd
Host: provider.ltd
Accept: application/json, text/javascript, */*; q=0.01
Connection: keep-alive
Accept-Encoding: br, gzip, deflate
Accept-Language: en-us
DNT: 1
Cookie: PHPSESSID=xxyxyxyxyxyxyxyyxyyyxy
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15
Referer: https://provider.ltd/
Content-Length: 43
X-Requested-With: XMLHttpRequest
Response
HTTP/1.1 200 OK
Content-Type: application/json
Pragma: no-cache
Date: Tue, 05 Jun 2018 10:29:04 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Server: Apache/2.2.22 (Debian)
Content-Length: 0
X-Powered-By: PHP/5.4.45-0+deb7u2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Connection: Keep-Alive
Keep-Alive: timeout=10, max=10000
Set-Cookie: login=+; expires=Tue, 05-Jun-2018 09:29:04 GMT; path=/; domain=lk.provider.ltd; secure; httponly
Set-Cookie: password=+; expires=Tue, 05-Jun-2018 09:29:04 GMT; path=/; domain=lk.provider.ltd; secure; httponly
Request Data
MIME Type: application/x-www-form-urlencoded; charset=UTF-8
username: someuser
password: somepass
/tool fetch http-method=post http-data="{\"username\":\"someuser\"\n\"password\":\"somepass\"}" url="https://provider.ltd/path-to-script.php"
, does not work
Answer the question
In order to leave comments, you need to log in
As usual, I asked myself, I answer myself:
/tool fetch http-method=post http-data="username=someuser&password=somepass" url="https://provider.ltd/path-to-script.php"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question