Secret User Agent Man!

torn up fortune cookie message

I was creating a PHP helper class to leverage the NPS Data API recently, and stumbled across an odd situation where I could successfully retrieve the API’s JSON result in Google Chrome with the ModHeader extension— but PHP’s file_get_contents function would fail with a Server 500 error.

After several ¬†Google searches, I stumbled across this post on Stack Overflow which got to the heart of the problem. It turns out PHP’s default user agent string for file_get_results is blank, and some web servers are configured to ignore requests with empty user agent strings. Once I added an Agent String in my PHP’s header request, it started to return results as expected.

Three Tries, Plus New Markers

My plans for this morning fell through, so I decided to take a stab at an idea for a doodle.  These things never turn out the way I envision them in my head, but I got a chance to try out my new markers.