Dotclear

source: plugins/kUtRL/inc/services/class.shortto.service.php @ 2190

Revision 2190, 1.5 KB checked in by JcDenis, 14 years ago (diff)

kUtRL 0.3:

  • Added DC 2.2 compatibility (new settings)
  • Added semi-custom hash on kUtRL service
  • Added status update for Twitter/Identi?.ca on new short link
  • Added services error management (first step)
  • Added options to widgets
  • Upgraded bitly service to v3
  • Changed admin design
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of kUtRL, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009-2010 JC Denis and contributors
6# jcdenis@gdwd.com
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13if (!defined('DC_RC_PATH')){return;}
14
15class shorttoKutrlService extends kutrlServices
16{
17     public $core;
18
19     public $id = 'shortto';
20     public $name = 'short.to';
21     public $home = 'http://short.to';
22
23     private $url_api = 'http://short.to/s.txt';
24     private $url_test = 'http://dotclear.jcdenis.com/go/kUtRL';
25
26     public function __construct($core,$limit_to_blog=true)
27     {
28          parent::__construct($core,$limit_to_blog);
29
30          $this->url_base = 'http://short.to/';
31          $this->url_min_length = 25;
32     }
33
34     public function testService()
35     {
36          $arg = array('url' => urlencode($this->url_test));
37          if (!self::post($this->url_api,$arg,true,true))
38          {
39               $this->error->add(__('Service is unavailable.'));
40               return false;
41          }
42          return true;
43     }
44
45     public function createHash($url,$hash=null)
46     {
47          $arg = array('url' => $url);
48
49          if (!($response = self::post($this->url_api,$arg,true,true)))
50          {
51               $this->error->add(__('Service is unavailable.'));
52               return false;
53          }
54
55          $rs = new ArrayObject();
56          $rs->hash = str_replace($this->url_base,'',$response);
57          $rs->url = $url;
58          $rs->type = $this->id;
59
60          return $rs;
61     }
62}
63?>
Note: See TracBrowser for help on using the repository browser.

Sites map