Services_ShortURL
[ class tree: Services_ShortURL ] [ index: Services_ShortURL ] [ all elements ]

Class: Services_ShortURL

Source Location: /Services_ShortURL-0.3.1/Services/ShortURL.php

Class Overview


An interface for managing short URLs


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 37]
An interface for managing short URLs


[ Top ]


Class Variables

$options = array()

[line 50]

Global options for services

Most short URL services have APIs that do not require anything special to interface with. Others, however, require API keys, usernames, etc. This is a global variable that can store those options to reduce repetitiveness.


Type:   array


[ Top ]

$services = array(
        'bit.ly'      => 'Bitly',
        'is.gd'       => 'Isgd',
        'tinyurl.com' => 'TinyURL',
        'digg.com'    => 'Digg',
        'tr.im'       => 'Trim',
        'goo.gl'      => 'Googl',
        'short.ie'    => 'Shortie'
    )

[line 57]

List of supported services
  • Var: Map of services to drivers
  • Access: protected

Type:   array


[ Top ]



Method Detail

addService   [line 175]

void addService( string $host, string $driver)

Add a service driver

You can easily create your own drivers and enable them globally using this method. Please submit your drivers if you're able to do so. We appreciate the help!

  • Access: public

Parameters:

string   $host   —  The hostname used by the shortening service
string   $driver   —  The name of the driver to be used

[ Top ]

detect   [line 118]

object Instance detect( string $url)

Detect service from a short URL

Takes a URL and inpects it to see if there is a service driver that can be used to expand it.


Parameters:

string   $url   —  The short URL to inspect

[ Top ]

extract   [line 143]

array extract( string $string)

Extract all short URLs and expand them from a string

This exception will take a given string (e.g. a blog post or a tweet), inspect it for supported short URLs and expand each of them. It then returns an array with the short URL as the key and the expanded URL as the value.


Parameters:

string   $string   —  The string to inspect for short URLs

[ Top ]

factory   [line 76]

object Instance factory( string $service, [array $options = array()])

Create an instance of a service driver

Parameters:

string   $service   —  Name of service driver
array   $options   —  Options for the given service

[ Top ]

setServiceOptions   [line 193]

void setServiceOptions( string $service, array $options)

Set global service options

To easily use the extract feature or not have to worry about setting options for everything you can globally set a service's options using this method. Services_ShortURL::factory() will then use options set by this method.

  • Access: public

Parameters:

string   $service   —  Service to set options for
array   $options   —  The options for the service

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:43:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.