summaryrefslogtreecommitdiff
path: root/src/plugins/SenderGVSMS.class.php
blob: 7919007bf49e7867c21c0b9eb0ad72aa5c6e8b98 (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
<?php

require_once('GoogleVoice.class.php');

class SenderGVSMS extends Plugin {
	protected $config = array('username'=>'',
	                          'password'=>'',
	                          'length'=>160);
	private $obj;
	
	public static function description() {
		return 'Send messages over SMS via GoogleVoice.';
	}
	
	public static function configList() {
		return array('username'=>'text',
		             'password'=>'password');
	}
	
	public function init() {
		$this->obj = new GoogleVoice($this->config['username'],
		                             $this->config['password']);
	}
	
	public function sendPrivate($phoneNum, $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->sms($phoneNum, $subject.' '.$url);
	}
}