Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auslesen Antwortnachricht #1

Closed
DanielNe opened this issue Jan 24, 2017 · 6 comments
Closed

Auslesen Antwortnachricht #1

DanielNe opened this issue Jan 24, 2017 · 6 comments

Comments

@DanielNe
Copy link

Mir wurde gesagt, dass mit dem Update nun auch die Antworten der Mitglieder ausgelesen werden können. Gibt es dafür ein Beispiel?

Vielen Dank!

LG

@pmig
Copy link
Contributor

pmig commented Jan 24, 2017

Hallo @DanielNe ,

Ich gehe davon aus, dass du dich auf die Dashboard API für deine Feuerwehr beziehst?

Die Antwortnachricht (participationMessage) ist Teil des AlarmRecipients, wie in der Dasboard API > AlarmRecipient beschrieben.

Folgender Beispiel Html und Javascript Code listet alle Alarmteilnehmer der letzten Alarme mit ihrem Status und ihrer Antwortnachricht auf:

index.html:

<script type="text/javascript">
	// FILL IN THE  SESSION ID BELOW
	var SESSION_ID = ''; // received after login


	var dashboardUrl = 'https://api.blaulichtsms.net/blaulicht/api/alarm/v1/dashboard/' + SESSION_ID;


	var displayParticipationMessage = function(dashboardJSON) {
		var dashboard = JSON.parse(dashboardJSON);

		dashboard.alarms.forEach(function(alarm) {
			alarm.recipients.forEach(function (recipient) {
				document.write(recipient.name + ' ' + recipient.participation + ' ' + recipient.participationMessage + '<br>');
			});
			document.write('<hr>');
		});
	};


	var loadDashboard = function(url, callback) {
	    var xmlHttp = new XMLHttpRequest();
	    xmlHttp.onreadystatechange = function() { 
	        if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
	            callback(xmlHttp.responseText);
	    }
	    xmlHttp.open("GET", url, true); // true for asynchronous 
	    xmlHttp.send(null);
	};


	loadDashboard(dashboardUrl, displayParticipationMessage);
</script>

Du musst nur noch deine Session ID hinterlegen.

Beachte bitte, dass das HTML file von einem Webserver (apache, nginx etc.) ausgeliefert werden muss, damit der Request auf die Blaulicht API klappt

Ich hoffe, dass ich dir helfen konnte.

@pmig pmig self-assigned this Jan 24, 2017
pmig pushed a commit that referenced this issue Jan 26, 2017
@pmig
Copy link
Contributor

pmig commented Jan 26, 2017

Hallo @DanielNe ,

Ich habe nun zu dem Javascript Beispiel auch ein PHP Beispiel für den Login und den Dashboard Request hinzugefügt.

@pmig pmig added the question label Jan 26, 2017
@DanielNe
Copy link
Author

Vielen Dank!.
Leider hat das noch nicht so funktioniert, bekomme keine Daten.
Wenn ich den API Link + Session in den Browser eingebe bekomme ich aber die Daten.
Oder funktioniert das nur bei Einsätzen und nicht bei infos?

Schön wäre ein "Demo Bereich" wo man alarme für tests anlegen könnte.

Vielen Dank!

@DanielNe
Copy link
Author

Frage hat sich selbst beantwortet.
Für Andere:

Auslesen Alarme:
dashboard.alarms.forEach
Auslesen Infos:
dashboard.infos.forEach

@pmig
Copy link
Contributor

pmig commented Jan 27, 2017

@DanielNe wir können dir natürlich einen kostenfreien serperaten Testzugang zur Verfügung stellen, damit du Testalarme versenden kannst, falls du daran Interesse hast, melde dich bitte ein unserem Kundensupport

@DanielNe
Copy link
Author

Vielen Dank für den Support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants