te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Google Map API key error "Your site URL to be authorized" - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Map API key error "Your site URL to be authorized" - Stack Overflow

programmeradmin2浏览0评论

I have searched many links and read documents related to google api key, but every time I am getting the only error of Your site URL to be authorized

I am creating a PhoneGap hybrid application where I am not sure if which URL I have to pass to google api key referrer so I am stuck here

What I am using for google script is:

<script src=";key=MY_API_KEY&sensor=false" type="text/javascript"></script>

Updated

I have already created Browse Key using google console but now What I have to pass in referrer link ( ? ) while I am creating a cordova application

I have searched many links and read documents related to google api key, but every time I am getting the only error of Your site URL to be authorized

I am creating a PhoneGap hybrid application where I am not sure if which URL I have to pass to google api key referrer so I am stuck here

What I am using for google script is:

<script src="https://maps.googleapis./maps/api/js?v=3&key=MY_API_KEY&sensor=false" type="text/javascript"></script>

Updated

I have already created Browse Key using google console but now What I have to pass in referrer link ( ? ) while I am creating a cordova application

Share Improve this question edited Jun 23, 2016 at 9:19 Kirankumar Dafda asked Jun 23, 2016 at 9:06 Kirankumar DafdaKirankumar Dafda 2,3845 gold badges31 silver badges59 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

I Dont know if this will help anyone but I spent a good hour trying to figure out this problem and ended up realizing I had the wrong API enabled. You need Google Maps JavaScript API enabled.Also sometimes you need to specify https.

1.Leave it blank 2.You need to enable the google maps api for your project.

  1. You need to enable the google maps api for your project.

  2. if your API key have no limitation and it still not work - trying to add signed_in=true to url. It helps for me.

This error means that the current URL loading the Maps JavaScript API has not been added to the list of allowed referrers. Please check the referrer settings of your API key in the Cloud Console. (source: https://developers.google./maps/documentation/javascript/error-messages#referer-not-allowed-map-error)

Go to the Google Cloud credentials page to add your website url: https://console.cloud.google./projectselector2/google/maps-apis/credentials

  1. Select the API key that you want to set a restriction on. The API key property page appears.

  2. Under Key restrictions, set the following restrictions:

    • Application restrictions:
      1. To accept requests from the list of website that you supply, select HTTP referrers (web sites) from the list of Application restrictions.
      2. Specify one or more referrer web sites. For example, *.google. accepts all sites ending in google., such as https://developers.google.. Note: file:// referers need a special representation to be added to the key restriction. The file:// part should be replaced with __file_url__ before being added to the key restriction. For example, file:///path/to/ should be formatted as __file_url__//path/to/*. After enabling file:// referers, it is remended you regularly check your usage, to make sure it matches your expectations.
  3. Save your changes

  4. You must include an API key with every Maps JavaScript API request. In the following example, replace YOUR_API_KEY with your API key.

    <script async defer src="https://maps.googleapis./maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>

(source: https://developers.google./maps/documentation/javascript/get-api-key#restrict_key)

发布评论

评论列表(0)

  1. 暂无评论