Google URL shortener class

Released 7 years ago , Last update 7 years ago

Shrink your way to long URLs with Google's URL shortener using PHP

With this class you can easily interact with the Google URL Shortener API. This class can shorten, expand or give statistics about a URL.

It will transform URLs like [www.binpress.com](http://www.binpress.com "www.binpress.com") into [goo.gl/snLNe](http://goo.gl/snLNe "goo.gl/snLNe") and vise versa.

Pricing

14 day 14-day money-back guarantee

$9.99

Personal License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

Get your personal API key

To retrieve your personal API key you have to log in to the API console and activate URL Shortener API. After that you can find your API key when clicking on the API access which can be found on the left side.

Usage

First of all you need to include the class:

<?php

include 'classes/googl.class.php';

To shrink a URL:

$goog = new googl('API KEY');

$goog->shorten('http://www.binpress.com');

Output: > { "kind": "urlshortener#url", "id": "http://goo.gl/snLNe", "longUrl": "http://www.binpress.com/" }

Expend a URL:

$goog = new googl('API KEY');

$goog->expand('http://goo.gl/snLNe');

Output: > { "kind": "urlshortener#url", "id": "http://goo.gl/snLNe", "longUrl": "http://www.binpress.com/", "status": "OK" }

Statistics from a short URL:

$goog = new googl('API KEY');

$goog->analytics('http://goo.gl/snLNe');

Output: > { "kind": "urlshortener#url", "id": "http://goo.gl/snLNe", "longUrl": "http://www.binpress.com/", "status": "OK", "created": "2011-02-04T00:39:29.607+00:00", "analytics": { "allTime": { "shortUrlClicks": "9", "longUrlClicks": "17", "referrers": [ { "count": "9", "id": "Unknown/empty" } ], "countries": [ { "count": "4", "id": "US" }, { "count": "3", "id": "NL" }, { "count": "1", "id": "FR" }, { "count": "1", "id": "IL" } ], "browsers": [ { "count": "5", "id": "Firefox" }, { "count": "2", "id": "Safari" }, { "count": "1", "id": "Chrome" }, { "count": "1", "id": "Mobile" } ], "platforms": [ { "count": "3", "id": "Other Unix" }, { "count": "2", "id": "Macintosh" }, { "count": "2", "id": "iPhone" }, { "count": "1", "id": "Linux" }, { "count": "1", "id": "Windows" } ] }, "month": { "shortUrlClicks": "3", "longUrlClicks": "3", "referrers": [ { "count": "3", "id": "Unknown/empty" } ], "countries": [ { "count": "3", "id": "NL" } ], "browsers": [ { "count": "3", "id": "Firefox" } ], "platforms": [ { "count": "3", "id": "Other Unix" } ] }, "week": { "shortUrlClicks": "3", "longUrlClicks": "3", "referrers": [ { "count": "3", "id": "Unknown/empty" } ], "countries": [ { "count": "3", "id": "NL" } ], "browsers": [ { "count": "3", "id": "Firefox" } ], "platforms": [ { "count": "3", "id": "Other Unix" } ] }, "day": { "shortUrlClicks": "3", "longUrlClicks": "3", "referrers": [ { "count": "3", "id": "Unknown/empty" } ], "countries": [ { "count": "3", "id": "NL" } ], "browsers": [ { "count": "3", "id": "Firefox" } ], "platforms": [ { "count": "3", "id": "Other Unix" } ] }, "twoHours": { "shortUrlClicks": "3", "longUrlClicks": "3", "referrers": [ { "count": "3", "id": "Unknown/empty" } ], "countries": [ { "count": "3", "id": "NL" } ], "browsers": [ { "count": "3", "id": "Firefox" } ], "platforms": [ { "count": "3", "id": "Other Unix" } ] } } }

1 license From » $9.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
No comments have been posted yet.