Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: search Arguments: Description: An API that will search for cartoons by author, keyword, or category and return results as JSON or as XML Page type: webl Render function: Module: perfectCartoon Page source: var author = wubinfo.restargs["author"] ? ""; var keyword = wubinfo.restargs["keyword"] ? ""; var category = wubinfo.restargs["category"] ? ""; var format = wubinfo.restargs["format"] ? "json"; if (author == "") and (keyword == "") and (category == "") then var categories = ["Accounting","Advertising","Business","Career","Coffee","Committees", "Communication","Computers","Consultants","Customer Service","Data","Doctors", "Economics","Education","Energy","Ethics","Entrepreneur","Environment", "Farming","Government","Green","Hospitals","Human Resources","Innovation", "Laid Off","Leadership", "Legal","Management","Women Management","Manufacturing", "Marketing","Meetings","Mergers","Mindfulness","News Media","Politics", "Military","Motivation","Negotiation","Presentation","Procrastination","Sales", "Science","Self-Deprecating","Social Media","Start-Ups","Statistics","Strategy", "Suggestions","Real Estate","Regulations","Taxes","Teaching","Technology", "Warning Signs","Wealth","Work","Workaholic","Working from Home","Animals","Anger","Apology", "Babies","Birthday","Books","Breaking Up","Cats", "Careers","Coffee","Crayons","Dating","Death","Diet","Dieting","Divorce", "Doctors","Dogs","Education","Elderly","Exercise","Feelings","Finances","Flying", "Gardening","Gay","Genetics","God","Grammar","Happiness","Hats", "Health","Hugs","Interior Design","Joy","Kids","Lemmings","Life Coach", "Love","Men","Mindfulness","Negative Attitude","New York", "Parenting","Parties","Pharmacy","Pharmaceutical","Piano","Politician", "Procrastination","Questions","Reading","Relationship","Restaurant","Sports", "Social Media","Suggestions","Teasers","Technology", "Therapy","Time","Travel","Trees","UFO","Unemployed ","Vegan", "Warning Signs","Wealth","Wedding","Wine","Women","Yoga"]; category = categories[Wub_RandomInt(Size(categories))] end; var matches = WubCall("perfectCartoon.searchCartoons", ["", keyword, category, author, "en"]); var r2 = []; var i = 0; every match in matches.res do if i < 25 then r2 = r2 + [ [. pageUrl = match.pageUrl, imgUrl = match.imgUrl, author=match.author, title = match.text .] ] end; i = i + 1 end; var res; if (format == "json") then res = ToString(WubCall("toJSON", [r2])); else var wrapper = [. label="xml", version="1.0" .]; var data = r2; var options = [. cdata = "true" .]; res = ToString(WubCall("toXML", [wrapper, data, options])); res = ToString(r2) end; NewPage(res, "text/html");