0

EDIT: This is the page where you can find all the error stuff: http://google.intellectproductions.com/

I'm using this example for Google Search API:

<html>
  <head>
    <title>JSON/Atom Custom Search API Example</title>
  </head>
  <body>
    <div id="content"></div>
    <script>
      function hndlr(response) {
      for (var i = 0; i < response.items.length; i++) {
        var item = response.items[i];
        // in production code, item.htmlTitle should have the HTML entities escaped.
        document.getElementById("content").innerHTML += "<br>" + item.htmlTitle;
      }
    }
    </script>
    <script src="https://www.googleapis.com/customsearch/v1?key=YOUR-KEY&cx=017576662512468239146:omuauf_lfve&q=cars&callback=hndlr">
    </script>
  </body>
</html>

However, that has a flaw in it and I have no idea why.

My script tag url is this:

<script src="https://www.googleapis.com/customsearch/v1?key={{MY KEY}}&cx=012495781369301842149:acs-gv099hu&q=runescape&callback=hndlr">
</script>

But with both examples it is giving me this error:

Uncaught TypeError: Cannot read property 'length' of undefined 

Why would they post something that has an error in it?

Peanut
  • 3,153
  • 7
  • 28
  • 47
  • Have you tried `console.log(response);`? Or any kind of debugging at all? – Ry- Apr 28 '13 at 17:11
  • Whenever I paste that code inside the function for the first line to be read, it just keeps showing a blank page with no helpful information. – Peanut Apr 28 '13 at 17:12
  • It just says [object Object] – Peanut Apr 28 '13 at 17:13
  • In which browser? You should be able to click on it and get its properties… – Ry- Apr 28 '13 at 17:13
  • I'm in Chrome.. It just says this: hndlr googlesearch.localhost:12 (anonymous function) – Peanut Apr 28 '13 at 17:15
  • Sorry, where are you putting it? That sounds like a stack trace. – Ry- Apr 28 '13 at 17:16
  • IT says something like 403 – Peanut Apr 28 '13 at 17:16
  • error: Object code: 403 errors: Array[1] 0: Object length: 1 __proto__: Array[0] message: "Access Not Configured" __proto__: Object __proto__: Object – Peanut Apr 28 '13 at 17:17
  • So you haven’t configured the API yet, I’d assume. Is the key right and active? Did you follow all the steps? Is there a domain restriction that’s not being met? (I don’t remember much about how Google APIs work.) – Ry- Apr 28 '13 at 17:18
  • I just generated a new key and did that one and it's giving me the same error. It has nothing to do with the key. The response.items.length is the part that is throwing the error because it's not catching any value for response. – Peanut Apr 28 '13 at 17:20
  • It’s giving you an error message that’s pretty descriptive — I would still assume it has something to do with your service. Have you tried [looking the error up](https://duckduckgo.com/?q=403+Access+Not+Configured)? [This question](http://stackoverflow.com/questions/8498084/403-access-not-configured-when-adding-event-to-calendar), for example, seems promising. – Ry- Apr 28 '13 at 17:21
  • Yes I have tried looking everywhere hence the reason I posted here.. I've been at this for the past 3 hours.. – Peanut Apr 28 '13 at 17:22
  • Now it's giving me an error code of 400 – Peanut Apr 28 '13 at 17:24
  • Everytime I refresh it gives me a new error code. Now its 403 – Peanut Apr 28 '13 at 17:24

0 Answers0