Skip to content

Instantly share code, notes, and snippets.

@tjnicolaides
Created February 3, 2012 04:43
Show Gist options
  • Save tjnicolaides/1728032 to your computer and use it in GitHub Desktop.
Save tjnicolaides/1728032 to your computer and use it in GitHub Desktop.
E_Interactive Blog Tool SOAP XML Request
// XML from Basestation Blog SOAP API -- AJAX
// - requires jQuery
$(document).ready(function() {
blogID = "1001334";
entriesRequested = "25";
payload = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> ' +
' <soap:Body> ' +
' <GetXMLBlogsContent xmlns="http://www.emmisinteractive.com/"> ' +
' <BlogIDs>' + blogID + '</BlogIDs> ' +
' <NumberOfItems>' + entriesRequested + '</NumberOfItems>' +
' <StartDate></StartDate> '+
'</GetXMLBlogsContent>'+
' </soap:Body>'+
'</soap:Envelope>';
$.ajax({
type:'POST',
url:'http://www.ei_domain.com/_shared/content/public/blogservice.asmx?op=GetXMLBlogsContent',
dataType:"xml",
contentType: "text/xml; charset=\"utf-8\"",
data:payload,
success: function(xml){
//LOOPS BLOG ENTRIES + STORES ENTRY DATA INTO MASTER ARRAY
$(xml).find("BlogEntries").find("BlogEntry").each(function(e){
//PUSHES ENTRY VARIABLES/JSON OBJECT INTO MASTER ARRAY
blogVariables.push({
"blogURL": $(this).parents("Blog").attr("BlogURL"),
"blogID" : $(this).parents("Blog").attr("BlogID"),
"blogIMG" : $(this).parents("Blog").attr("BlogImageURL"),
"url": $(this).parents("Blog").attr("BlogEntryURL"),
"blogName" : $(this).parents("Blog").attr("BlogName"),
"title": $(this).attr("EntryTitle"),
"entryID" : $(this).attr("BlogEntryID"),
"pubDate" : $(this).attr("UTCDateTimePublished"),
"image": $(this).find("Images").find("Image").attr("ReducedImageURL"),
"author" : $(this).attr("AuthorName"),
"description" : "<div>" + $(this).find("EntryDescription").text() + "</div>",
"audio" : $(this).find("AudioFile").attr("AudioURL")
});
});
},
error: function() {
console.log("Error");
}
}, "xml");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment