php
Using the PetFinder API
From Petfinder:
Overview
The Petfinder API gives developers access to access Petfinder's database of over 300,000 adoptable pets and 11,000 animal welfare organizations (AWO). In addition to searching for adoptable pets on the Petfinder.com web site, you can use the API to create your own dynamic pet web sites or applications, using the same data we use on Petfinder.com.
Here is what I did for http://www.laneparkdogs.com/adopt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php header("Content-Type: application/json"); require_once('Cache/Lite.php'); $lastOffset=$_REQUEST["offset"]; $id = $lastOffset; $options = array( 'cacheDir' => '/tmp/', 'lifeTime' => 18000 ); $Cache_Lite = new Cache_Lite($options); if ($contents = $Cache_Lite->get($id)) { } else { $API_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $API_PUBLIC = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $API_URL = "http://api.petfinder.com/"; $API_COMMAND = "pet.find"; $options = "?key=".$API_PUBLIC."&animal=dog&location=43220&offset=".$lastOffset."&count=10&output=full&format=json"; $request = $API_URL.$API_COMMAND.$options; $handle = fopen($request, "r"); $contents = stream_get_contents($handle); fclose($handle); $Cache_Lite->save($contents); } print($contents); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | <html> <head> <script src="/misc/jquery.js" type="text/javascript"></script> <style type="text/css"> .clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; } .clearfix { display: inline-block; } html[xmlns] .clearfix { display: block; } * html .clearfix { height: 1%; } </style> <script type="text/javascript"> var currentOffset = 0; function getPets() { $("#loader").css( { "background-image":"url(/petfinder/ajax-loader.gif)", width:"220px", height:"19px" }); $("#btnMore").hide(); $("#loader").show(); var url = "/petfinder/"; var data = {offset:currentOffset}; $.getJSON(url, data, function(resp) { currentOffset = parseInt(resp.petfinder.lastOffset.$t, 10); var pets = resp.petfinder.pets.pet; $(pets).each(function(i, item) { $("#pets").append(formatPet(item)); }); $("#loader").hide(); $("#btnMore").show(); }, "json"); } function formatPet(pet) { var div = $("<div class='clearfix'></div>"); var name = pet.name.$t; $(div).append("<strong>"+name+"</strong> <br />"); var desc = $("<div class='clearfix'>"+pet.description.$t+"</div>"); if(pet.media.photos.photo.length > 0) { var img = $("<img />") .attr("src", pet.media.photos.photo[0].$t) .attr("alt", name) .attr("align", "left") .css({ border:"solid 2px gainsboro", padding:"3px", margin:"5px", width:"200px" }); $(desc).prepend(img); } $("a", desc).attr("target", "_blank"); $(div).append(desc).append("<hr />").css({padding: "4px", margin:"3px"}); return div; } $(document).ready(function() { getPets(); $("#btnMore").click(function() { getPets(); }); }); </script> </head> <body> <noscript>Javascript is required.</noscript> <div class="clearfix" id="pets"></div> <div id="loader" style="width: 220px; height: 19px; line-height: 19px; vertical-align: middle; text-align: center;"> Loading... </div> <input id="btnMore" type="button" value="View More" /> </body> </html> |
Codestock
CodeStock is about Community. For Developers, by Developers (with love for SysAdmins and DBAs too!). Last year an idea started at CodeStock to mix Open Spaces within a traditional conference. This year we're going to crank things up to 11 and rip off the knob - and you're being drafted to help!
CodeStock On Web
If you've blogged about CodeStock, let us know!
Read A Letter to the Community on CodeStock 2009 by CodeStock Organizer, Michael C. Neel
- Checkout Alan Stevens talking about Open Spaces and CodeStock on .Net Rocks!
- CodeStock 2009, a must attend event
- CodeStock 2009: We Want You!
- Vote for me!
- I may be speaking at CodeStock
- Upcoming Events I'm Looking Forward To (Part 2)
- I Might Be Speaking at CodeStock
- Presenting at CodeStock 2009 dot dot dot question mark
- Codestock Session Submissions
- Upcoming events in the area
- I might be Speaking at CodeStock – or watching Shawn Wildermuth
- I Might Be Speaking at CodeStock
- The Software/Tech Conference Season is Here
- Want to speak at CodeStock?
- Codestock 2009 is fast approaching...
- Speaking Opportunities Abound in the Heartland!
- Tennessee Technical Conferences: devLink and Codestock
- CodeStock 2009 “Call for Speakers” is Open
- Relive last year's CodeStock at wiki.codestock.org

