Skip to content

dartist/goog_url_shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Url Shortener in Dart

A small library and application that shortens and expands urls using dart and google shortener apis.

Usage

Library

Installing from pub.dartlang.org apply the following to pubspec.yaml

dependencies:
  goog_url_shortener: any

Installing from this git repo apply the following to pubspec.yaml

dependencies:
  goog_url_shortener: 
  	git: git://github.com/financeCoding/goog_url_shortener.git

Importing the library

import 'package:goog_url_shortener/goog_url_shortener.dart';

Example of calling the shortener

  SecureSocket.initialize();
  UrlShortener urlShortener = new UrlShortener(url: url,
                                               command: type,
                                               key: key);
  var furture = urlShortener.execute(); 
  furture.then((Map data) {
    print('Long Url = ${data["longUrl"]}');
    print('Short Url = ${data["id"]}')
  });                                         

SecureSocket.initialize() needs to be called to set the built in client certificates for the socket.

Tool

The goog_url_shortener.dart in bin/ could be used as a standalone commandline tool for shortening or expanding urls.

Shorten a url
$ ./bin/goog_url_shortener.dart -u http://www.dartlang.org -t shorten
Long Url = http://www.dartlang.org/
Short Url = http://goo.gl/8l3PM
Expand url
$ ./bin/goog_url_shortener.dart -u http://goo.gl/8l3PM -t expand
Long Url = http://www.dartlang.org/
Short Url = http://goo.gl/8l3PM
Help
$ ./bin/goog_url_shortener.dart -h
-c, --curl               absolute path for curl
                         (defaults to "curl")

-k, --key                google api key
-u, --url                url
                         (defaults to "http://www.google.com")

-t, --type               type of action to execute

          [analytics]    analytics for the url
          [expand]       expand the url
          [shorten]      shorten the url

-h, --help               help

TODO

Add an example of creating a cert database.

About

Simple url shortener using google shortener api and curl

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages