Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
api key
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dan  
View profile  
 More options Jun 16 2007, 7:24 pm
From: Dan <dl...@urbanschool.org>
Date: Sat, 16 Jun 2007 16:24:19 -0700
Local: Sat, Jun 16 2007 7:24 pm
Subject: api key
Hello,

If I have a website with multiple domains pointing to it, what would
you suggest to do about API keys since the key only works for one of
the domains?

Thanks,
Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jgeerdes  
View profile  
 More options Jun 16 2007, 8:45 pm
From: jgeerdes <jgeer...@mchsi.com>
Date: Sat, 16 Jun 2007 17:45:52 -0700
Local: Sat, Jun 16 2007 8:45 pm
Subject: Re: api key
Use javascript to parse the domain from the document.location.href,
and then write the external script tag with the appropriate key.

Jeremy R. Geerdes
Effective Website Design & Development

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgeer...@mchsi.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan  
View profile  
 More options Jun 16 2007, 10:39 pm
From: Dan <dl...@urbanschool.org>
Date: Sat, 16 Jun 2007 19:39:51 -0700
Local: Sat, Jun 16 2007 10:39 pm
Subject: Re: api key
What does parse the domain mean?

Thanks,
Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jgeerdes  
View profile  
 More options Jun 17 2007, 4:19 pm
From: jgeerdes <jgeer...@mchsi.com>
Date: Sun, 17 Jun 2007 13:19:57 -0700
Local: Sun, Jun 17 2007 4:19 pm
Subject: Re: api key
To parse the domain name, you want to look at document.location.href
and use a regular expression to pull the domain name of the document's
absolute URL.  Assuming that you've set up your API keys based on your
primary domains (e.g., mysite.com), I would do something like this:

var gMapKeys = [];
gMapKeys['mysite.com'] = '...';
gMapKeys['yoursite.org'] = '...';
gMapKeys['thissite.net'] = '...';
gMapKeys['thatsite.us'] = '...';
var loc = document.location.href.match(/^https?:\/\/.*?\.(.*?)\/?/i)
[1];
document.write('<script type=text/javascript src="http://
maps.google.com/maps?file=api&amp;v=2&amp;key="'+gMapKeys[loc]+'"></
script>\n');

You would want to make sure that this happens as the page is loading
(i.e., not in the onload).

Jeremy R. Geerdes
Effective Website Design & Development

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgeer...@mchsi.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Hunter  
View profile  
 More options Jun 17 2007, 5:05 pm
From: "Barry Hunter" <barrybhun...@googlemail.com>
Date: Sun, 17 Jun 2007 22:05:06 +0100
Local: Sun, Jun 17 2007 5:05 pm
Subject: Re: api key

Using document.location.host, is easier than using .href :) It also means
you test it in the same way that Google does in the API code ;)

On 6/17/07, jgeerdes <jgeer...@mchsi.com> wrote:

--
Barry

- www.nearby.org.uk - www.geograph.org.uk -


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Geary  
View profile  
 More options Jun 17 2007, 11:16 pm
From: Michael Geary <M...@Geary.com>
Date: Sun, 17 Jun 2007 20:16:28 -0700
Local: Sun, Jun 17 2007 11:16 pm
Subject: Re: api key
If anyone would like a nice simple piece of code to handle the API
keys for multiple domains, try this:

   <script type="text/javascript"> document.write(
      '<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=' +
      {
         'example.com': 'api-key-for-example.com',
         'anotherexample.com': 'api-key-for-anotherexample.com'
      }[location.host] +
      '" type="text/javascript"><\/script>' );
   </script>

-Mike

On Jun 17, 2:05 pm, "Barry Hunter" <barrybhun...@googlemail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jp  
View profile  
 More options Jul 3 2007, 11:41 am
From: jp <jdp...@gmail.com>
Date: Tue, 03 Jul 2007 08:41:50 -0700
Local: Tues, Jul 3 2007 11:41 am
Subject: Re: api key
Hi,

Is there a way in this code to have default value for this code if it
doesn't match any of the domains? eg:

'example.com': 'api-key-for-example.com',
'anotherexample.com': 'api-key-for-anotherexample.com'
default: 'fail'

thanks

John

On Jun 18, 4:16 am, Michael Geary <M...@Geary.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
warden  
View profile  
 More options Jul 3 2007, 11:59 am
From: warden <andrew.leac...@googlemail.com>
Date: Tue, 03 Jul 2007 08:59:17 -0700
Local: Tues, Jul 3 2007 11:59 am
Subject: Re: api key
On Jul 3, 4:41 pm, jp <jdp...@gmail.com> wrote:

> Hi,

> Is there a way in this code to have default value for this code if it
> doesn't match any of the domains? eg:

> 'example.com': 'api-key-for-example.com',
> 'anotherexample.com': 'api-key-for-anotherexample.com'
> default: 'fail'

Have you tried the code? The default key ends up as "undefined".

However, you can define your own default thus:

<script type="text/javascript"> document.write(
      '<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=' +
      ({
         'example.com': 'api-key-for-example.com',
         'anotherexample.com': 'api-key-for-anotherexample.com'
      }[location.host] || 'mydefaultvalue') +
      '" type="text/javascript"><\/script>' );
   </script>

Andrew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »