Simple Webservice that outputs JSON - web-services

I want to build a simple web service that outputs JSON to test a parser on iPhone.
I have considered using public apis like twitter etc but I want to use a custom JSON text for a small proof of concept test.
I am using a MAC with Apache.
I got the web server up and I can access an HTML page saying Hello World from 127.0.0.1
Can someone guide me as to how can I modify the HTML such that when I post a NSURLRequest, all I get back is JSON text. Not JSON in HTML/XML but plain JSON text.
Something like -http://twitter.com/statuses/public_timeline.json
Any leads much appreciated.
Thanks
Dev.

Got it right here - http://www.youtube.com/watch?v=7k-suIGS_1k
Just in case some one else is looking for the same thing.

Related

Populate web page using API result directly from API server

Firstly sorry if this question has been asked before but I'm a novice so even if it has I'm unaware of the language I'd even use to try and seek it out.
I'm beginning to learn about REST API's and it got me thinking. Is it possible to load the JSON response directly from the API server into the user's browser and bypass your own server?
Imagine you have say a Django app running on a server that accesses email messages from Outlook.com using the graph API.
I assume an ordinary flow would go something like:
User request->your server->graph api-> your server-> user browser.
It seems like a waste for it to hit your server that second time before it goes on to be presented to the user's browser.
Is there a way the Django app can render a template and effectively tell the browser "expect some data from X source, and place it in y location in this template"?
You could do that with javascript. You'd have to include either a script tag in your template, or create and include some static javascript files with the code.
I'd recommend learning and using the jQuery javascript library, as it makes what you're talking about much easier to implement. Research ajax requests, those are what you'll need to make requests directly to another server, bypassing your own

Web crawler: web content does not show up in html code

I am doing a basic web crawler work for this web page (just for study purpose, and I have got their permission):
http://www.seattle.gov/council/calendar#/?i=0
What I wanted to do is to get all the events' "Time", "Description" and "Location" in that form. I have tried python regular expression however it looks like these information does not show up in the HTML code of this page. Instead, I am using a Selenium, but I still don't know where to find this information.
Sometimes, things are in front of you but you don't see them.
You can fetch/extract that data from their RSS Feed. It's here: http://www.trumba.com/calendars/seattle-city-council.rss
Hope this helps.

How to send a post request via excel to a RESTful Web Service without using XML?

Here's the deal: I had a excel table that fulfills a MySQL table. I already made a procedure in server side who receives the sheet, read it and put it on the database. Saddly the sheet and data table doesn't have the same structure, so I need to use a php object/script in server side to manipulate it. I have a interface to upload the file (excel file), so the PHP program can read it...
...but my boss job isn't make my life easier, is it? NO! He says that is a lot of work have to upload every excel file by the web interface. So, he asked me to make a button in the sheet that he might click after his "job" is done. That would replace the web interface.
But, the system itself is a interface that would be saled one day (well, it's the plan!). So, I just can't just role out the web interface.
WHAT I'M ASKING IS: There's a way that I could send a file (the sheet itself) in a post method straight from the VBA Macro without using XML files and name each data that I'm sending, like a form post?
So far, I've found some tutorials or even some SO posts that made me get somewhere. But all of them were talking about a XML, and I already have a method that receives a HTTP POST (from a form) and work. I aiming to reuse the same method. From my VBA script I'm already able to make the request (not a big deal) and post it. But, in the server-side script, I'm expecting a POST come out from a form, so it calls a field's name. I don't seen to be able to do that from a VBA post. =/
Here's the answer... the two first functions/methods define how to send a file to a web service. You only need the file path and the URL from service. It has answered even more than I expected. :D

How to retrieve WCF service link in flex using httpservices

I want to retrieve server content which is like wsdl link(WCF service URL)using FLEX 4.5.. I haven't worked with webservices on FLEX. I have worked with xml data retrieval using httpservices where I had a local xml datas. Right now, i am trying to retrieve a server content. I have provided with the service link, method name and xml tags. (seems like parameters).. Since this is the first time im trying the server content, I need some help. Your help is highly appreciated.. thanks in advance... Would be better if i can get a sample project on webservices.
This is what I'm trying. The service link is below.
http://mfsapi.blisslogix.net/RSS_FEEDS_SERVICE.svc
When I click on this link, i'm getting the below link.
http://mfsapi.blisslogix.net/RSS_FEEDS_SERVICE.svc?wsdl
where I can see a lot of tags.
I am using HTTPSERVICES and WEBSERVICES to work on this issue and i'm not getting the xml data. I guess I did some mistake on passing the parameters. Please walk me through the steps how can I pass the method and parameters with this link..
First you need to create a WebService tag. Or use ActionScript an object of type WebService.
<mx:WebService id="myWebService"
useProxy="false"
showBusyCursor="true"
load="OnServiceLoad(event)"
fault="OnFault(event)">
<s:operation name="GetInformation" result="onLoad(event)" fault="onFault(event)">
</s:operation>
</mx:WebService>
Then you need to specify the WSDL document location and load it.
myWebService.loadWSDL("http://mfsapi.blisslogix.net/RSS_FEEDS_SERVICE.svc?wsdl");
Then you can simply call the operations specified in the WebService tag.
myWebService.GetInformation();
Here is a link on how to communicate with web services using MXML and AS.

How does IE downloading is achieved?

I often click on a file link in the IE and a download box just pops out. But what happens behind this scene? I know that IE always talks to web server with HTTP protocol, and HTTP is text based.
So is IE download achieved with HTTP protocol? If so, how could arbitrary file format be downloaded over a text based protocol?
And I am currently trying to make a web app which will direct my customer to download some file. My current design is to implement a web service. Customer will call this web service and the web service will return the file download URL. But then I don't know what to do with the URL. Could I just use something like File.Copy to copy the file from the URL to local disk? Or how should I treat the URL? If there's a better design, please teach me.
Many thanks...
By specifying the right content type, you can tell the browser what kind of data it is you are sending.
In addition, there are special encodings (like Base 64) that allow binary content to be displayed as text, using only a limited set of characters and escaping everything else.
Then, there is nothing you need to do with the url. IE will know whether it can or cannot open the file and will show the download box accordingly.
maybe it's like
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>