API: PHP Shorten URL using googles URL shortening service


Looking for PHP api to make url shortened using Here is the solution.. PHP API to shorten your URL..

Just get Google API key form and use it in the code below. That’s it. You will have your URL entered in line 1 shortened in last echo statement in the code below. 🙂 API: PHP

Below is the video explaining how you can get api key.

Or, please login using google or facebook and create a forum topic to get your query answered in few hours here

Follow me

Sachin Wable

Sachin Wable is a technical blogger. He is blogging since 2010 & writes about Blogging, affiliate marketing & technical stuff. His blog receives 22,500 page views and visits from 1934 cities from 135 countries per year. (As per last years google analytics report.)
Follow me

Latest posts by Sachin Wable (see all)

Sharing is cool...Share on Facebook
Tweet about this on Twitter
Share on LinkedIn



  1. Alex says:

    Awesome! Thanks for the post.

  2. Norman says:

    Works like a charm! You are great!

  3. Flavio Carvalho says:

    I Keep getting the error

    Notice: Undefined property: stdClass::$id in C:\xampp\htdocs\URL Shortner.php on line 26
    Shortened URL ->

    The API Key is OK, I dont know how to fix it.

    • Sachin Wable says:

      Hi Flavio,

      Have you tried copying same code and changing only API key as I have shown in video? If yes, it should work. I can see you are trying to run on local machine. Make sure you have curl enabled on your local server or try executing script on some hosting where we ideally have curl enabled. 🙂


  4. José says:

    Everything is fine thanks
    now as consulting statistics Short URL?

Leave a Reply

Your email address will not be published. Required fields are marked *