Forked from DinisCruz-Dev/1. Get request with current data.groovy
Created
October 10, 2015 21:31
-
-
Save anselmoshim/e9517485e3df4374674a to your computer and use it in GitHub Desktop.
Misc Groovy Scripts that invoke the Firebase APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def firebaseJsonData = "https://incandescent-fire-1320.firebaseio.com/.json?print=pretty" | |
def data = firebaseJsonData.toURL().getText() | |
return data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def firebaseJsonData = "https://incandescent-fire-1320.firebaseio.com/.json?print=pretty" | |
def data = firebaseJsonData.toURL().getText() | |
def javascriptEditor = eclipse.registry.editor("JavaScript Editor"); | |
eclipse.editors.open_String_in_Editor(javascriptEditor,data); | |
return javascriptEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="US-ASCII"> | |
<title>Firebase test</title> | |
<script src='https://cdn.firebase.com/js/client/1.0.6/firebase.js' ></script> | |
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script> | |
</head> | |
<script> | |
var myRootRef = new Firebase('https://incandescent-fire-1320.firebaseio.com'); | |
//myRootRef.push({name: 'Now using PUSH', text: 'Hello World Again!'}); | |
//myRootRef.set("Value from Javascript"); | |
myRootRef.on('child_added', function(snapshot) | |
{ | |
//message = snapshot.valueOf().val(); | |
//displayChatMessage("message", message); | |
message = snapshot.val(); | |
displayChatMessage(message.name, message.text); | |
}); | |
function displayChatMessage(name, text) | |
{ | |
$('<div/>').html(text).prepend($('<em/>').text(name+': ')) | |
.appendTo($('#messagesDiv')); | |
}; | |
</script> | |
<body> | |
Messages: | |
<div id="messagesDiv"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def firebaseUrl = "https://incandescent-fire-1320.firebaseio.com/.json"; | |
dataToSubmit = ' { "name" : "Groovy" , ' + | |
' "text" : "Hello there from Groovy" }' | |
def connection = firebaseUrl.toURL().openConnection() | |
connection.setDoOutput(true) | |
connection.setRequestMethod("POST"); | |
connection.outputStream.withWriter { | |
Writer writer -> writer << dataToSubmit; | |
}; | |
def response = connection.inputStream.withReader { Reader reader -> reader.text } | |
return response; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment