Sometimes you want to share your website pages with twitter. You can shorten the page urls with a JavaScript API, but it slows down terribly your website.
This plugin asks only once for the shorten url, then cache it in database for later access.
git clone git://github.com/ornicar/dmBitLyPlugin.git plugins/dmBitLyPlugin
class ProjectConfiguration extends dmProjectConfiguration { public function setup() { parent::setup(); $this->enablePlugins(array( // your enabled plugins 'dmBitLyPlugin' ));
php symfony doctrine:generate-migrations-diff
php symfony doctrine:migrate
php symfony dm:setup
Get a login and an api key at http://bit.ly/account/register?rd=/
And configure the service with them:
config/dm/services.yml
parameters:
bit_ly_api.login: mylogin
bit_ly_api.api_key: R_fd1ff8d93e3a646myapikey
Shorten a url:
$shortUrl = $this->getService('bit_ly_api')->shorten($longUrl);
The first time, a request will be sent to bit.ly, to get the short url. Then it's stored in your database, and next time there will be no more external call.
dmBitLyPlugin, created on March 25, 2010 by Thibault D, used by 22 projects