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.

WordPress and PHP 7

multiple Uno cards, all of them are sevens.

After months of procrastination, I finally upgraded this website to PHP 7. I had visions of diagnosing and fixing broken plugins, but everything works as it should– no deprecated function calls, etc.

I take that back. Everything feels like it works faster than it did, particularly inside the admin dashboard.