title: Using javascript to access Google's URL shortener APIs in a Google Chrome extension
body: <p>I am writing my first google chrome extension which will use <a href="https://developers.google.com/url-shortener/" rel="noreferrer">Google's URL shortener api</a> to shorten the URL of the currently active tab in Chrome.</p>
  
  <p>I am a longtime sw developer (asm/C++) but totally new to this "webby" stuff. :)</p>
  
  <p>I can't seem to figure out how to make (and then process) the http POST request using js or jquery. I think I just don't understand the POST mechanism outside of the curl example.</p>
  
  <p>My javascript file currently looks like this:</p>
  
  <pre><code>chrome.browserAction.onClicked.addListener(function(tab) { 
      console.log('chrome.browserAction.onClicked.addListener');
  
  chrome.tabs.getSelected(null, function(tab) {
      var tablink = tab.url;
      console.log(tablink);
  
      //TODO send http post request in the form
      // POST https://www.googleapis.com/urlshortener/v1/url
      //   Content-Type: application/json
      //   {"longUrl": "http://www.google.com/"}
  });
  </code></pre>
  
  <p>});</p>