I've been working on Basecamp API integration and I find it too sluggish using Cakephp's HttpSocket, Xml loader using Set::reverse. Anyone have tried working similar?
What my code does is provide the API token as required by Basecamp parsed Xml into array and return parsed XML to calling procedures.
I'm not sure if I understood your qestion right, but maybe the XML helper is what you are looking for.
Related
I have an api controller which generates response as xml and need to pass this xml to an external angularjs application and parse this to show result.
I have tried this so far.
/PaymentSuccess.html?response=<xml>....<xml>
I dont think this is the best way of doing because the uri seems lengthy and ugly.
Is there any better way so that i can pass the xml to the uri and read that from the angular application.
Is there any way to get CRX content without using OSGI service?
Am looking for an use case to implement a top navigation for a website which is required to read page names and its properties via javascript framework like angular JS.
You could get it as JSON or XML, make a server call to path with extension XML or JSON. JSON allows you depth based selectors to go down the tree hierarchy not sure if its same with XML.
/my/page/path.xml or /my/page/path.<depth>.json, you can get the hostname and port details from the request URI to make the complete URL for the data call.
I would suggest you use the following JSON API's provided by sling to accomplish your task of getting page names and its properties.
Firstly to crawl all the pages under a given path, you need to use the .pages.json selector. For example to get all child pages of /content/company/en_US, perform a JSON GET on
HTTP GET <Host>/content/company/en_US.pages.json
Next for each path returned by the above GET call, you need to grab the _jcr_content.json of the page
(E.g.)
HTTP GET <Host>/content/company/en_US/home/_jcr_content.json
The above JSON call should provide you all the page properties of this particular page.
Please Note: The above method is generic and can be applied to any JCR Path hosted in Sling/AEM. Also typically you cannot get this level of JCR access in a publisher environment due to security rules that might prevent JCR crawling. Hope this helps
Recently I started to work with Web API. I work ok, but I want to return data in json. It now returns records in XML. Please guide me
Chrome does that by default, it return xml if you simply try your URL in the browser. There is a way to tell the api to only return json, you basically have to remove the xml serialiser and only leave in the json one:
configuration.Formatters.Clear();
configuration.Formatters.Add(new JsonMediaTypeFormatter());
reference :
http://www.strathweb.com/2013/06/supporting-only-json-in-asp-net-web-api-the-right-way/
Is it viable to consume XML Response from a Webservice by posting xml using angular JS. Any suggestions would be helpfull.
One option can be just convert the xml object to the json object
https://code.google.com/p/jquery-xml2json-plugin/
I'm not able to fetch data from xml using backbone.js. No proper example is given on the sites I checked.
Take a look at BackboneJS with XML ajax
Basically, you need to overwrite the model/collection's parse method to build an object form the XML response.
In addition, you need to overwrite the requested data type, as it is json by default.