How to enter api key in my javascript file


#1

Hello,

Im currently working on a school project. But I’m getting an error in my console that im not authorized, which makes sence because I have not entered any keys (which I have by the way). I just dont know where and how to enter them. This is what I got so far.

Instamap
    <script src="js/jquery.js"></script>
	<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
	<script>
    
        
    $(document).ready(function() {
                console.log(">> Done Loading");

});

Can anyone tell me where to enter the twitter keys and consumer key and secret key etc.

Thanks,

Mark


#2

Anyone


#3

Hey Mark, I don’t see any Twitter-specific code in the sample you’ve pasted here. It looks like you’re loading jQuery, a Google Maps library, and then jQuere again (!), but nothing that tries to access Twitter? Am I missing something about what you are trying to achieve?


#4

I have this piece of code too:

function buttonClick(event) { console.log("Click"); alert ("Ok");
var twitter_zoek_url= "http://search.twitter.com/search.json?q=kip&lang=nl";
$.ajax(
    {
        url:twitter_zoek_url ,
        success: toonTweets,
        dataType: 'jsonp',
    }
);

}


#5

Got this now:

$(document).ready(function() { var url = 'https://api.twitter.com/1.1/search/tweets.json?q=%40twitterapi';
    $.ajax({
          dataType: "json",
          url: url,
          success: success

});
function success(){
console.log(“data found”);

       };
                console.log("hoi");
  
                });

and getting this error: XMLHttpRequest cannot load https://api.twitter.com/1.1/search/tweets.json?q=%40twitterapi. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access.