<?php
namespace app\extensions\service;
class Twitter extends \lithium\http\Service {
protected $_api = array(
'statuses' => array(
'user_timeline' => array(
'path' => 'statuses/user_timeline',
'method' => 'get',
'params' => array(
'id', 'user_id', 'screen_name', 'since_id', 'max_id', 'count', 'page'
)
),
'update' => array(
'path' => 'statuses/update',
'method' => 'post',
'params' => array(
'status', 'in_reply_to_status_id', 'lat', 'long',
)
)
)
);
public function __call($name, $options) {
if (isset($this->_api[$name])) {
$call = array_shift($options);
if (isset($this->_api[$name][$call])) {
extract($this->_api[$name][$call]);
$args = array_shift($options);
return $this->{$method}("{$name}/{$call}.json", $args);
}
}
}
public function send($method, $path = null, $data = null, $options = array()) {
$this->request->headers('User-Agent', 'twittium');
$data = parent::send($method, $path, $data, $options);
if (get_magic_quotes_gpc() == true) {
$data = stripslashes($data);
}
return json_decode($data);
}
}