java - Google Url shortner giving error for url with Ip -
i using google url shorten api. shorten url "http://demos.companyname.com:1339/"
but when replace url "http://demos.companyname.com:1339/" "http://36.186.69.8:1339/" returns error.
how solve problem?
my url shorten code is:
public jsonobject getjsonfromurl(string address,string longurl) {
    // making http request     try {         // defaulthttpclient         defaulthttpclient httpclient = new defaulthttpclient();         httppost httppost = new httppost(address);          httppost.setentity(new stringentity("{\"longurl\":\""+ longurl+"\"}"));         httppost.setheader("content-type", "application/json");         httpresponse httpresponse = httpclient.execute(httppost);          httpentity httpentity = httpresponse.getentity();         = httpentity.getcontent();      } catch (ioexception e) {         e.printstacktrace();     }      try {         bufferedreader reader = new bufferedreader(new inputstreamreader(                 is, "iso-8859-1"), 8);         stringbuilder sb = new stringbuilder();         string line = null;         while ((line = reader.readline()) != null) {             sb.append(line).append("\n");          }         is.close();         log.e("getjsonfromurl: ", sb.tostring());         json = sb.tostring();         log.e("json", json);     } catch (exception e) {         log.e("buffer error", "error converting result " + e.tostring());     }      // parse string json object     try {         jobj = new jsonobject(json);     } catch (jsonexception e) {         log.e("json parser", "error parsing data " + e.tostring());     }     // return json string     return jobj;  }   error response:
   {"error":{"errors":          [{"domain":"global","reason":"invalid","message":"invalidvalue","locationtype":"parameter","location":"resource.longurl"}],"code":00,"message":"invalid value"}}      
as of knowledge, google url shortener not work ip, worked mapped url.
check below link know if google can shorten url or not.
Comments
Post a Comment