Forum » Programiranje » Apache2, php, web service POST request problem
Apache2, php, web service POST request problem
Šmorn ::
Imam napravo, ki pošilja podatke na strežnik po http POST requestu. Napisati moram testni strežnik za shranjevanje podatkov. Postavil sem WAMP, problem pa je, ker se na programiranje spletnih servisov ne spoznam ravno najbolje. Workflow je sledeč:
1. Naprava se registrira na strežnik. Ta del sem rešil tako, da sem v mapi www/provision naredil activate.php datoteko s funkcijo, ki vrne unique id. Za test sem uporabil fiksen string, ki sem ga vzel iz dokumentacije: f75fab38b23b56e767f178677c5df3a4eed5120f. Ta del mi dela. Naprava je prejela ID. Besedilo iz dokumentacije:
* Sent to Server*
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 42
HTTP POST "/provision/activate"
vendor=novus&model=logbox3gstd&sn=00001232
* Received from the server *
HTTP/1.1 200
Date: Mon, 27 Aug 2018 13:40:32 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 40
Server: nginx
f75fab38b23b56e767f178677c5df3a4eed5120f
2. Ko je naprava registrirana na strežniku, periodično pošilja POST request na strežnik. Tu se mi ustavi. Mislil sem narediti podobno, kot pod točko 1, samo ne vem, kaj pomeni : v urlju. Windows pač ne dovoli : v imenu mape. Dokumentacija:
* Sent to Server*
Content-Type: application/json; charset=utf-8
User-Agent: Novus (suporte@novus.com.br)
Content-Length: 738
HTTP POST "/onep:v1/rpc/process"
{"auth":{"cik":"f75fab38b23b56e767f178677c5df3a4eed5120f"},"calls":[
{"id":1,"procedure":"recordbatch","arguments":[{"alias":"3GRECDTD"},[[1535376780,0]]]},
{"id":2,"procedure":"recordbatch","arguments":[{"alias":"3GRECESV"},[[1535376772,2.3950
00E+01]]]},
{"id":3,"procedure":"recordbatch","arguments":[{"alias":"3GRECBTP"},[[1535376772,1.0000
00E+02]]]},
{"id":4,"procedure":"recordbatch","arguments":[{"alias":"3GRECCJV"},[[1535376772,2.2400
00E+01]]]},
{"id":5,"procedure":"recordbatch","arguments":[{"alias":"3GRECGPSP"},[[1535376772,"0"]]
]},
{"id":6,"procedure":"recordbatch","arguments":[{"alias":"3GRECUC1V"},[[1535376772,1.880
000E+01]]]},
{"id":7,"procedure":"recordbatch","arguments":[{"alias":"3GRECUC2V"},[[1535376772,1.940
000E+01]]]}
]}
* Received from the server *
HTTP/1.1 200 OK
Date: Mon, 27 Aug 2018 13:33:06 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 162
Server: nginx
[
{"id":1,"status":"ok"},
{"id":2,"status":"ok"},
{"id":3,"status":"ok"},
{"id":4,"status":"ok"},
{"id":5,"status":"ok"},
{"id":6,"status":"ok"},
{"id":7,"status":"ok"}
]
Vsakršna pomoč je dobrodošla.
1. Naprava se registrira na strežnik. Ta del sem rešil tako, da sem v mapi www/provision naredil activate.php datoteko s funkcijo, ki vrne unique id. Za test sem uporabil fiksen string, ki sem ga vzel iz dokumentacije: f75fab38b23b56e767f178677c5df3a4eed5120f. Ta del mi dela. Naprava je prejela ID. Besedilo iz dokumentacije:
* Sent to Server*
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 42
HTTP POST "/provision/activate"
vendor=novus&model=logbox3gstd&sn=00001232
* Received from the server *
HTTP/1.1 200
Date: Mon, 27 Aug 2018 13:40:32 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 40
Server: nginx
f75fab38b23b56e767f178677c5df3a4eed5120f
2. Ko je naprava registrirana na strežniku, periodično pošilja POST request na strežnik. Tu se mi ustavi. Mislil sem narediti podobno, kot pod točko 1, samo ne vem, kaj pomeni : v urlju. Windows pač ne dovoli : v imenu mape. Dokumentacija:
* Sent to Server*
Content-Type: application/json; charset=utf-8
User-Agent: Novus (suporte@novus.com.br)
Content-Length: 738
HTTP POST "/onep:v1/rpc/process"
{"auth":{"cik":"f75fab38b23b56e767f178677c5df3a4eed5120f"},"calls":[
{"id":1,"procedure":"recordbatch","arguments":[{"alias":"3GRECDTD"},[[1535376780,0]]]},
{"id":2,"procedure":"recordbatch","arguments":[{"alias":"3GRECESV"},[[1535376772,2.3950
00E+01]]]},
{"id":3,"procedure":"recordbatch","arguments":[{"alias":"3GRECBTP"},[[1535376772,1.0000
00E+02]]]},
{"id":4,"procedure":"recordbatch","arguments":[{"alias":"3GRECCJV"},[[1535376772,2.2400
00E+01]]]},
{"id":5,"procedure":"recordbatch","arguments":[{"alias":"3GRECGPSP"},[[1535376772,"0"]]
]},
{"id":6,"procedure":"recordbatch","arguments":[{"alias":"3GRECUC1V"},[[1535376772,1.880
000E+01]]]},
{"id":7,"procedure":"recordbatch","arguments":[{"alias":"3GRECUC2V"},[[1535376772,1.940
000E+01]]]}
]}
* Received from the server *
HTTP/1.1 200 OK
Date: Mon, 27 Aug 2018 13:33:06 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 162
Server: nginx
[
{"id":1,"status":"ok"},
{"id":2,"status":"ok"},
{"id":3,"status":"ok"},
{"id":4,"status":"ok"},
{"id":5,"status":"ok"},
{"id":6,"status":"ok"},
{"id":7,"status":"ok"}
]
Vsakršna pomoč je dobrodošla.
Šmorn ::
Po postavitvi strežnika v Debianu in namestitvi mod_rewrite zadeva vsaj približno dela. Tole imam v .htaccess datoteki:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^onep\:v1/rpc/process$ /process.php? [L]
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^onep\:v1/rpc/process$ /process.php? [L]
Spura ::
Nekdo je bil mal prevec clever pa je dal : v URL, to ni nic takega. Je pa annoying ce si hotel kar z direktoriji delat. Sej si napisal rewrite rule, torej je zadeva resena?
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Davčna blahajna - PHP - certifikatiOddelek: Programiranje | 1041 (807) | app5771283 |
» | PHP POST težavaOddelek: Programiranje | 1628 (1494) | DeeJay |
» | [Ubuntu server] mail poslan iz serverja zazna kot vsiljeno pošto (strani: 1 2 )Oddelek: Omrežja in internet | 9136 (8106) | shorvat |
» | Hotmail.com označi moj smtp kot spamOddelek: Omrežja in internet | 2746 (2473) | kronik |
» | HTTP POSTOddelek: Programiranje | 1755 (1531) | kopernik |