I'm new to Blogger and its JSON API. I've found out I can retrieve all posts / retrieve specific post using post id.
I'm trying to build a lazy loading blogger post list page, where blog content needs to fetch dynamically. What is the best way to retrieve latest 5 posts in every request? (I don't want to request 5 times for 5 posts)
Another thing is, I want to show post's first image on post list page. How can I fetch the first image and fetch textual content only?
I've searched Google but couldn't find any good tutorial. I hope you guys can help me.
Cheers
One option is to use javascript callbacks , for example :
http://jayunit100.blogspot.com/feeds/posts/default?alt=json-in-script&callback=myFunc
This will return back a peice of executable javascript code which
1) Calls a function which you defined
2) Sends that function a json object
The below is my speculation on this matter, because it clearly is much more difficult than one might think it should be:
It is not clear to me why a simpler, pure, authentication-free JSON REST api is not available (maybe one does exist), which simply takes a blog id and returns pure text, however, I suspect it might be that blogger wants to discourage crawling.
http://blogname.blogspot.com/feeds/posts/default?alt=json
Replace blogname with you Blogname.
You will get JSON Object and use JSON FORMATTER to format the JSON.
Related
I'm implementing a small image uploading function in my web page, nothing too fancy, and to that end, I think vgy.me is a good tool. From what I understand, we can upload an image to the site via a POST method in a form. It returns a JSON response for every image uploaded, which contains a link to the image among other things (important because I intend to use that link for future purposes). There's even a helpful little example of the same on its API page (link).
My question is, how can I get that JSON response for my use using vanilla JavaScript? My initial searches have turned out techniques which pertain to server-side, which obviously I can't implement because it isn't my server I'm using. Is there a way to use the default POST method of HTML to get the JSON value, or perhaps I've misinterpreted the instructions?
I'm not using the jQuery code given on the page, because I've no knowledge of any JavaScript framework, and I'd rather not simply copy and paste if I could help it.
I am developing my first website. At this time i am generating a new html design that would be a ticket.
From my main page, i will load this html when the user clicks the "See ticket" button. This html has a table which is filled on document.ready with javascript. The data used is a JSON created in the main page.
I coded a working solution using localStorage. The problem is that the next step is to convert that HTML website to PDF and the software i am using does not work properly with localStorage, so i need to pass the JSON from main page to the ticket page. I can't neither use URL encoding cause string could be sometimes longer than 2000 characters and it is not productive.
So i thought that maybe i could do and $.get call from the ticket.html to index.html and get the needed JSON. Is this approach correct, or is there any better solution?
Regards
As suggested earlier comments, you need to use serverside code to accept post params and you need to do a ajax post to send the data. This is very good approach. I have one more idea for implementing this.
Let say you open ticket.html in a window.open. And have a JS function ( say GetValue) in index.html, that returns JSON . So you need to get JSON in ticket.html.
You need to define a JS function in ticket.html , using windown.opener.GetValue() , you can get JSON value.
Hope, i am in same direction, which you need. If not, please clarify.
Other way, would be use iFrame and use message communication to pass large data between them, you are interested in this, please read this - https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage
I have a .html which is a form with some selects, inputs.. in JQuery Mobile. The form is generated dynamically because at first I ask to a web service for the data needed, so once I have the information from the server I start to 'paint' the html with Javascript (For example: if (string) document.write + ...) It is working fine but now I have to get that data and send it back to the server.
My doubt is that I don't know if there is a 'best' way to do it. I have thought in generate and store the ID's from each parameter and the type in a array at same time I paint them and after ask them about the values.
It could be done that way? I have read about generate an array when clicking 'submit' and then generate the parameters but I can't see it clearly because I don't send that data literally, I have to process it first generating and XML and that stuff.
I know it could sound like a mess =(, sorry for my english and thanks in advance.
EDIT:
This is an example of my JS code
So it could generate 1, 2, 3.. infinites Strings interfaces (well, not that much) so if I want a function to recollect the values of the 'inputs', 'selects'... generated, how could I do it?
Tutorial to form post
Basically you specify the form to post to a specific URL, and then you just need your server to handle the response. The link above should be helpful in figuring it out! Alternatively, you can use AJAX to send data as well. Let me know if you have any questions!
I am trying to build this application that when provided a .txt file filled with isbn numbers will visit the isbn.nu page for that isbn number by simply appending the isbn to the url www.isbn.nu/your isbn number.
After pulling up the page, I want to scan it for information about the book, and store that in an excel file.
I was thinking about creating a file stream of the url in Java, but I am not really sure how to extract the information from the html page. Storing the information will be done using the JExcel Java package.
My best guess would be using javascript to extract the information, but I don't know how to call the javascript from my java program.
Is my idea plausible? if not, what do you guys suggest I do.
my goal: retrieve information from an html page and store it in an excel file for each ISBN in a text file. There can be any number of isbn's in a text file.
This isn't homework btw, I am simply doing this for an organization that donates books to Sudan. Currently they have 5 people cataloging these books manually and I am one of them.
Jsoup is a useful tool for parsing a web page and getting data from it. You can do it in Java and it's pretty easy.
You can parse the text file, build the URL with a string, send it in with JSoup then use JSoup to parse out the information using the html tags on the page. Then you can store it out however you want. You really don't need to use Javascript at all if you're more comfortable with Java.
Example for reading a page and parsing it with Jsoup:
Document doc = Jsoup.connect("http://en.wikipedia.org/").get();
Elements newsHeadlines = doc.select("#mp-itn b a");
Use a div in which you load your link (example here how to do that http://api.jquery.com/load/).
After that when load is complete you can check what is the name of the div's or spans used in the webpage and get that content with val (http://api.jquery.com/val/) or text (http://api.jquery.com/text/)
Here is text from the main page of www.isbn.nu:
Please note that isbn.nu is designed for manual searching by individuals. It is not intended as an information resource for automated retrieval, nor as a research tool for companies. isbn.nu reserves the right to deny access based on excessive requests.
Why not just use the free Google books API that would return book details in XML format. There are many classes available in Java to parse XML feeds and would make your life much easier.
See http://code.google.com/apis/books/ for more info.
Here are the steps needed:
Create CURL request (you can use multiple curl requests)
Get body data
Parse data
Make excel file
You can read HTML information using this guide.
A simple solution might be to use a Google Docs spreadsheet function like ImportXML(URL,path-expression).
More information and examples here:
http://www.seerinteractive.com/blog/importxml-cookbook/
http://www.distilled.net/blog/distilled/guide-to-google-docs-importxml/
http://blog.ouseful.info/2008/10/14/data-scraping-wikipedia-with-google-spreadsheets/
I am wanting to write a small application that can pull RSS feeds from any RSS feed url. if anyone could give me very basic help on how to achieve this?
im only really starting out in the world on AJAX and this kinda stuff so any help would be appreciated.
Thanks
EDIT :- I am only trying to do this with Jquery and Ajax, I dont want to use PHP or any other server side code.
You want to first create an interface in HTML that allows one to read and subscribe to RSS feeds. You also need to find a way to store the RSS feeds subscribed.
Then you want to use AJAX to get the remote document. I assume you're doing this in jQuery as your tag indicate it does, so you can refer to this: http://api.jquery.com/jQuery.ajax/
Then, you need to parse the XML that's returned. Check out a RSS tutorial -> http://www.w3schools.com/rss/default.asp and use the jQuery library to parse the data (HTML is kinda like XML, so the jQuery methods still works for XML/RSS) -> http://think2loud.com/reading-xml-with-jquery/
Lastly. Display your data by constructing your interface with JavaScript.