summaryrefslogtreecommitdiff
path: root/src/plugins/SenderIdentica.class.php
blob: 4bb20c986128c98807bcdcfd1da873d3e8886672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

require_once('SenderBroadcast.class.php');
require_once('Identica.class.php');

class SenderIdentica extends SenderBroadcast {
	protected $config = array('username'=>'',
	                        'password'=>'',
	                        'length'=>140);
	private $obj;
	
	public static function description() {
		return '';
	}
	
	public static function configList() {
		return array('username'=>'text',
		             'password'=>'password',
		             'length'=>'int');
	}
	
	public function init() {
		$this->obj = new Identica($this->config['username'],
		                          $this->config['password']);
	}
	
	public function send($id, $subject, $body) {
		global $shorturl, $messenger;
		$url = $shorturl->get($messenger->id2url($id));
		$maxlen = $this->config['length']-(strlen($url)+1);
		if($maxlen < strlen($subject)) {
			$subject = substr($subject,0,$maxlen-3).'...';
		}
		$this->obj->updateStatus($subject.' '.$url);
	}
}