Print

Print


I just got this set up on our site, using php to parse the json response.
 You should be able to see the result on our staging port at:

http://catalog.ccrls.org:2082

...under the 'Bestsellers' menu in the top nav bar.

We're having to host the actual php pages on a separate web server, since
our ILS server can't be made to support it.  Being a total php newb, I
received some great help from the stackoverflow forum to get the script
working; would be happy to share that code with you, if you think it would
help.

I've also tagged these pages for google analytics, so that we can monitor
the traffic on them.  I doubt we would come anywhere near the 5000/day api
limit, but wanted to be sure.  And I suppose if we did, I could always
introduce some server-side caching to cut the number down.

Regards,

Doug


On Wed, Sep 28, 2011 at 12:28 PM, Nate Hill <[log in to unmask]> wrote:

> Anybody out there using the NY times best seller API to do stuff on their
> library websites?
> I can't figure out what's wrong with my code here.
> Data is returned as "null"; I can't seem to parse the response with jQuery.
> Any help would be supercool.
> I removed the API key - my code doesn't actually contain 'xxxx'.
> Here's the jQuery:
>
> jQuery(document).ready(function(){
>    $(function(){
>                    //json request to new york times
>                    $.getJSON('
>
> http://api.nytimes.com/svc/books/v2/lists/hardcover-fiction.json?&api-key=xxxx
> ',
>
>                    function(data) {
>                        //loop through the results with the following
> function
>                        $.each(data.results.book_details, function(i,item){
>                        //turn the title into a variable
>                        var bookTitle = item.title;
>                        $('#container').append('<p>'+bookTitle+'</p>');
>
>            });
>        });
>    });
> });
>
>
> Here's a snippet of the JSON response:
>
> {
>    "status": "OK",
>    "copyright": "Copyright (c) 2011 The New York Times Company.  All Rights
> Reserved.",
>    "num_results": 35,
>    "last_modified": "2011-09-23T12:00:29-04:00",
>    "results": [{
>        "list_name": "Hardcover Fiction",
>        "display_name": "Hardcover Fiction",
>        "updated": "WEEKLY",
>        "bestsellers_date": "2011-09-17",
>        "published_date": "2011-10-02",
>        "rank": 1,
>        "rank_last_week": 0,
>        "weeks_on_list": 1,
>        "asterisk": 0,
>        "dagger": 0,
>        "isbns": [{
>            "isbn10": "0399157786",
>            "isbn13": "9780399157783"
>        }],
>        "book_details": [{
>            "title": "NEW YORK TO DALLAS",
>            "description": "An escaped child molester pursues Lt. Eve
> Dallas; by Nora Roberts, writing pseudonymously.",
>            "contributor": "by J. D. Robb",
>            "author": "J D Robb",
>            "contributor_note": "",
>            "price": 27.95,
>            "age_group": "",
>            "publisher": "Putnam",
>            "primary_isbn13": "9780399157783",
>            "primary_isbn10": "0399157786"
>        }],
>        "reviews": [{
>            "book_review_link": "",
>            "first_chapter_link": "",
>            "sunday_review_link": "",
>            "article_chapter_link": ""
>        }]
>
>
> --
> Nate Hill
> [log in to unmask]
> http://www.natehill.net
>



-- 
Doug Yancey
Chemeketa Cooperative Regional Library Service
Web Services Librarian
503.315.4268
Need support from CCRLS? Open a ticket at http://swhelpdesk.ccrls.org/portal