working with a googleAPIKey and subdomain of localhost

Though all googleAPIKeys work when you run your code at http://localhost or http://localhost/any/sub/directory/, I ran into a bit of a problem with my development server's key once I tried running the site we're developing at http://projectname.localhost/.

It turns out, that Google wanted me to register for an API key for my localhost subdomain.

Now by adding this else if everything is working swimmingly.

PHP:
  1. if ($_SERVER["HTTP_HOST"] == "projectname.dev.naterkane.com"){ //for development server
  2. $googleAPIKey = "ABQIAAAAXDA3g3QE28o3DpCEOJaK7RRbiuQmYjiTrMm7iJcFkjKKtES62BTJwMA8r_9--PPf1lirxSLFF7AjoA";
  3. } else if ($_SERVER["HTTP_HOST"] = "projectname.localhost"){ //for local development subdomain
  4. $googleAPIKey = "ABQIAAAAXDA3g3QE28o3DpCEOJaK7RQd8-PxSvU34sqHMt5i1yPetZP44hRjKyK727DILgg9wBKEDitvz4a0tg";
  5. } else { //catchall for "localhost" and default production domain
  6. $googleAPIKey = "ABQIAAAAzIcwHNZqp-D2TJm3qjeWyxQjCl-yVJ0Kz7eVNz89X4I7MZtKDxSog71ziTBuu1ICptxfQLN7rq9Xag";
  7. }

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus

Similar Posts

Categories

Archives

About

Nater Kane is freelance developer and user experience & technology consultant based in Brooklyn, NY.

Nater's focus is on creating a semantic and accessible web, and having delighted clients with happy customers.

He likes to spend time playing with his cats, playing drums, working on his diesel vw rabbit and his motorcycle, and enjoying a decent espresso.

RSS

Twitter » What I'm Up To

  • ok time for bed, it's not like i won't be up in four hours or anything... 3 hrs ago
  • it's 2am so i'm eating my lunch from today, finally. 3 hrs ago
  • time to grab a FAAAAAST lunch. damn today is flying by. 16 hrs ago
  • More updates...

How I'm Social

Basecamp

Meta


Nater Kane naterkane personal http://www.naterkane.com LinkedIn Profile Web Technologist personal nater@naterkane.com 1978-09-12 voice 845.234.6698 | fax 707.922.0593
964 Flushing Ave. Brooklyn, NY 11206