drGoogleUrlShortenerPlugin - 1.0.0

An interface to the Goolge URL Shortener API

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

drGoogleUrlShortenerPlugin

This plugin provides a Google URL Shortener API implementation and some nice shortcuts for getting a short URL for a given long URL or vice versa, and also for getting some statistics about the number of clicks, etc.

Dependencies

This plugin depends on the sfWebBrowserPlugin.

Install

Copy the plugin files to your /plugins directory and enable the plugin in your /config/ProjectConfiguration.class.php file:

class projectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->enablePlugins(array(
      // ...
      'drGoogleUrlShortenerPlugin',
    ));
  }
}

Acquire a Google API key via the Google APIs Console, switch the URL Shortener API to On and copy your API key to your app.yml:

all:    
  google:
    api_key: '7264hf89723hdfmnfg23u087hxcmhcHjd8d6732'

Usage

You may use the drGoogleApi*Call classes provided by the plugin in your own custom way, but most of the time it would be enough to use:

drGoogleUrlShortener::shorten('http://www.symfony-project.org', sfConfig::get('app_google_api_key'));

Or from within your template or partial:

use_helper('drGoogleUrlShortener');
 
echo google_shorten_url('http://www.symfony-project.org'); // the helper will fetch your API key from app.yml

TODO

  • This plugin doesn't work with OAuth, so your queries to the Google API will be limited to a certain amount per day (currently 1,000,000 requests)