HannaAbiAkl / bitly-api

Automatically exported from code.google.com/p/bitly-api
0 stars 0 forks source link

CORS fails for &format=txt request #38

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
cross-origin resource sharing requests fails when format=txt is used

exact same request with format=xml or without format= works cross domain

Original issue reported on code.google.com by paolocas...@gmail.com on 16 Mar 2011 at 2:23

GoogleCodeExporter commented 8 years ago
Can you provide an example call, or describe which api endpoint this is in 
reference to?

Original comment by jehiah on 16 Mar 2011 at 2:29

GoogleCodeExporter commented 8 years ago
I'm using this code, with my login/key pair.
It works for xml, but if I change to format=txt I get a cross origin exception 
from google chrome 10.

function shorten_url_with_bitly(myUrl) {
  var bitly_login = "xxx";
  var bitly_apiKey =  "yyy";
  var bitly_request = "http://api.bitly.com/v3/shorten?login=" + bitly_login + "&apiKey=" + bitly_apiKey + "&longUrl=" + encodeURIComponent(myUrl);

  var bitly_link = null;
  try {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", bitly_request + "&format=xml");
    xhr.onreadystatechange = function() {
      if(xhr.readyState == 4) {
        if(xhr.status==200) {
          // something done here after a successful request
        }
      }
    }
    xhr.send();
  }
}

Original comment by paolocas...@gmail.com on 16 Mar 2011 at 2:39

GoogleCodeExporter commented 8 years ago
thanks for the example; this should be fixed now.

Original comment by jehiah on 16 Mar 2011 at 3:06

GoogleCodeExporter commented 8 years ago
correct, this seems to be fixed now

Original comment by paolocas...@gmail.com on 16 Mar 2011 at 3:17