Benutzer-Werkzeuge

Webseiten-Werkzeuge


dapnetapisendrubricl

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
dapnetapisendrubricl [2018/03/13 14:06] – angelegt dh3wrdapnetapisendrubricl [2026/01/30 13:08] (aktuell) – Fix urls dj7lc
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 ===== 
 + 
 +===== HAMNET =====
  
 <code> <code>
-$c = REST::Client->new(); $c->setHost("$dapnethost:$dapnetport"); +curl -H "Content-Type: application/json" -X POST -u yourcallsign:yourpassword -d '{ "rubricName": "rubric", "text": "this is the message" }' http://dapnet.db0sda.hamnet.radio:8080/news 
-$c->addHeader('Authorization'=>'Basic ' . encode_base64($dapnetuser . ':' . $dapnetpw));+</code>
  
-$c->POST('/news', '{"rubricName": "dx-kwcw", "text": "'.$nachricht.'", "number": '.$pos.'}', {"Content-type"=>'application/json'});+===== INTERNET ===== 
 + 
 +<code> 
 +curl -H "Content-Type: application/json" -X POST -u yourcallsign:yourpassword -d '{ "rubricName": "rubric", "text": "this is the message" }' http://hampager.de/api/news 
 +</code> 
 + 
 + 
 +===== Example for python3 ===== 
 + 
 +<code> 
 +import requests 
 + 
 +# HAMNET 
 +url = 'http://dapnet.db0sda.hamnet.radio:8080/news' 
 + 
 +# INTERNET 
 +#url = 'http://hampager.de/api/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> 
 +$c = REST::Client->new(); 
 +$c->setHost("$dapnethost:$dapnetport"); 
 +$c->addHeader('Authorization'=>'Basic ' . encode_base64($yourcallsign . ':' . $yourpassword)); 
 +$c->POST('/news', '{"rubricName": "rubric", "text": "'.$message.'", "number": '.$pos.'}', {"Content-type"=>'application/json'}); 
 +</code> 
 + 
 +===== set a specific position for the skyper rubric content ===== 
 + 
 +Valid positions are integers as char from 1 to 10 
 +<code> 
 +{ "rubricName": "rubric", "text": "this is the message", "number": position }
 </code> </code>
dapnetapisendrubricl.1520949970.txt.gz · Zuletzt geändert: 2018/03/13 14:06 von dh3wr