Tuesday, May 12, 2015

php making easy things easy

Good lord, I know I'm not impressing anyone by digging on PHP, but man does it do a good job making easy things easy.

I picked PHP for the core of my http://jpporchfest.org/ work because I figured if I ever shared with other groups, it was easier for them to dig up a server with that installed, plus I knew from experience it has a lot of convenient things baked-in. (Unlike the old days with me and Perl and wrestling with CPAN archives) When I wanted to make a simple client hitting Google's Map API for some geocoding, man was it easy. I figured I'd have to at least use a "curl" module of some kind but the default file_get_contents() function reads URLs no problem... json_decode(result, true) that and I'm on my way with a bunch of associative arrays.

PROTIP: I didn't want to flood the Google API (it has some kind of rate limit) so I put in a sleep 0.5 between requests, but that was causing the page not to render until every request had been made. The flush() command prevented that from being a problem.

No comments:

Post a Comment