1

I'm currently using Goo.gl to keep track of various ads I'm posting on the internet. I would like to do the same with phone number links (ex: href="tel:15555555555") but I'm completely lost on how to do this.

I'm basically trying to keep track of my phone conversions in a free way, and I thought of this as being a great option if I can just figure it out...

Any Ideas?

Joseph Chillemi
  • 168
  • 1
  • 1
  • 12

1 Answers1

-1

Shorten Url using Goo.gl here json data send in http header as post request.

send variable by using redirect url method in longUrl

{'longUrl': 'https://www.google.com'}

this loginUrl is send as post request in http header and google.com is finally created as a shorten url.

public void sendPostBody() throws Exception {

   String url = "https://www.googleapis.com/urlshortener/v1/url?key=YOUR_GENERATED_KEY"; //Generated your own key on your google account

   HttpClient client = new DefaultHttpClient();
   HttpPost post = new HttpPost(url);

   // add header
   post.setHeader("Content-type","application/json");

   post.setEntity(new StringEntity("{'longUrl': 'https://www.google.com'}", "UTF8"));

   HttpResponse response = client.execute(post);

   BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

   StringBuffer result = new StringBuffer();
   String line = "";
   while ((line = rd.readLine()) != null) {
    result.append(line);
   }
  System.out.println(" The shorten Goo.gl Url is :::: "+result.toString());
  }

This result contains a json in format like this:

{ "kind": "urlshortener#url", "id": "YourShorternURL", "longUrl": "https://www.google.com"} 

Your Shorten URL is the "id" parameter in the JSON.

Source: http://adityagoyal-java.blogspot.in/2016/09/shorten-url-using-googl-by-http-post.html