Benutzer-Werkzeuge

Webseiten-Werkzeuge


dapnetapisendrubricl

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
Letzte Überarbeitung Beide Seiten der Revision
dapnetapisendrubricl [2018/03/13 15:06]
dh3wr
dapnetapisendrubricl [2022/01/30 13:22]
dj7lc [Example for python3]
Zeile 1: Zeile 1:
 ====== Send rubric content via REST-API ====== ====== Send rubric content via REST-API ======
  
-Just an example in Perl from https://github.com/DecentralizedAmateurPagingNetwork/DxClusterInterface/blob/master/dxclusterspider_db0sda+===== Example for curl from linux console ===== 
 + 
 +<​code>​ 
 +curl -H "​Content-Typeapplication/json" -X POST -u yourcallsign:​yourpassword -d '{ "​rubricName":​ "​rubric",​ "​text":​ "this is the message"​ }' http://dapnet.db0sda.ampr.org:​8080/news 
 +</code> 
 + 
 + 
 +===== Example for python3 ===== 
 + 
 +<​code>​ 
 +import requests 
 + 
 +url = 'http://dapnet.db0sda.ampr.org:​8080/​news'​ 
 + 
 +headers = {'​Content-type':​ '​application/​json'​} 
 + 
 +data = '{ "​rubricName":​ "​rubric",​ "​text":​ "this is the message"​ }' 
 + 
 +data = data.encode('​utf-8'​) 
 + 
 +response = requests.post(url,​ headers=headers,​ auth=('​yourcallsign',​ '​yourpassword'​),​ data=data) 
 + 
 +print(response) 
 +</code> 
 + 
 +===== Example for pearl =====
  
 <​code>​ <​code>​
 $c = REST::​Client->​new();​ $c = REST::​Client->​new();​
 $c->​setHost("​$dapnethost:​$dapnetport"​);​ $c->​setHost("​$dapnethost:​$dapnetport"​);​
-$c->​addHeader('​Authorization'​=>'​Basic ' . encode_base64($dapnetuser ​. ':'​ . $dapnetpw)); +$c->​addHeader('​Authorization'​=>'​Basic ' . encode_base64($yourcallsign ​. ':'​ . $yourpassword)); 
- +$c->​POST('/​news',​ '​{"​rubricName":​ "rubric", "​text":​ "'​.$message.'",​ "​number":​ '​.$pos.'​}',​ {"​Content-type"​=>'​application/​json'​});​
-$c->​POST('/​news',​ '​{"​rubricName":​ "dx-kwcw", "​text":​ "'​.$nachricht.'",​ "​number":​ '​.$pos.'​}',​ {"​Content-type"​=>'​application/​json'​});​+
 </​code>​ </​code>​
dapnetapisendrubricl.txt · Zuletzt geändert: 2022/01/30 13:27 von dj7lc