DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Amazon REST API For NewLISP
;; (amazon-op "Operation=ItemSearch&SearchIndex=Books&ItemPage=1&Keywords=Cloud+Atlas&Respon\ seGroup=Request,Small") ;; ;; (amazon-op "Operation=SimilarityLookup&ItemId=1400063795,0812966929&SimilarityType=Random\ &ResponseGroup=Request,Large") ;; (amazon-op "Operation=SimilarityLookup&ItemId=1400063795,061873516X,0812966929&Similarity\ Type=Random&ResponseGroup=Request,Small") ;; (setq x (xml-digest (amazon-op "Operation=ItemLookup&ItemId=0375507256&ResponseGroup=Req\ uest,Similarities,ListmaniaLists"))) ;; Using x get a list of listmanias for an item ;; (map (lambda (x) (x 1 2 2)) (1 -1 (x (chop (ref 'ListmaniaLists x))))) ;; (setq y (amazon-op "Operation=ListLookup&ListType=Listmania&ListId=R21LV6VJEZ794O&Respons\ eGroup=ListFull")) ;; Using y get a list of ISBNs from a listmania ;; (map (lambda(x) (x 4 1 2 )) (8 -1 ( (y (chop (ref 'Lists y)) ) 2))) ; gives list of ISBNs\ from the listmania ;; get a list of listmania details from a list of listmanias. ;; (setq z (map (lambda (x) (xml-digest (amazon-op (append "Operation=ListLookup&ListType\ =Listmania&ListId=" x "&ResponseGroup=ListFull")))) (map (lambda (x) (x 1 2 2)) (1 -1 (x (c\ hop (ref 'ListmaniaLists x)))))) ) ;; ;; get a list of ISBNs from all of the listmanias for the item ;; (setq z (flat (map (lambda(y) (map (lambda(x) (x 4 1 2 )) (8 -1 ( (y (chop (ref 'Lists y)\ ) ) 2))) ) z))) ;; ;; get item info for all the ISBNs from all listmanias related to the original item ;; (setq w (map (lambda (x) (xml-digest (amazon-op (append "Operation=ItemLookup&ItemId=" x)\ ))) (unique z))) ;; get a list of pair (title,author) from w above. ;; (map (lambda (x) (list ((x (chop (ref 'Title x))) 1) (if (ref 'Author x)((x (chop (ref '\ Author x)))1) "???"))) w) (define (amazon-op params) (get-url (append "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&&AWSAccessKeyId=YOUROWNKEY&" params))) (define (xml-digest result) (xml-type-tags nil nil nil nil) (setq xresult (xml-parse result (+ 1 2 4 8 16))))





