июня 23, 2012 | Комментариев нет
мая 22, 2012 | Комментариев нет
ТЗ: организовать релевантный поиск.
ТУ: данные хранятся в MongoDB, бэкенд на PHP.
Читать полностью »
CodeIgniter,
HowTo,
MongoDB,
NoSQL,
PHP,
Sphinx,
Алгоритмы,
Кодинх,
Новости,
Программирование,
Проектирование 
IAD
Warning: count(): Parameter must be an array or an object that implements Countable in
/var/www/html/wp-content/themes/amlet/archive.php on line
31
декабря 7, 2011 | Комментариев нет
Качаем ericmann-gReader-Library с гитхаба.
Сразу проезжаемся рубанком, заменяя private на protected, иначе нельзя обратиться к методам и свойствам при расширении класса extends.
Задача: вытянуть из Google Reader записи, отмеченные звёздочками (starred) и отослать информацию о снятии звёздочки
Решение, расширяем базовый класс двумя методами:
include_once 'ericmann-gReader-Library/greader.class.php';
class google_reader extends JDMReader
{
public function __construct()
{
}
public function connect($username, $password)
{
parent::__construct($username, $password);
}
// List a particular number of unread posts from the user's reading list
public function getStarred($limit) {
$gUrl = 'http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/starred';
$args = sprintf('n=%2$s&ck=%3$s&client=GoogleReaderDashboard', time() - (7*24*3600), $limit, time());
$data = $this->_httpGet($gUrl, $args);
$decoded_data = json_decode($data, true);
$feed_items = $decoded_data['items'];
return($feed_items);
}
/**
* Mark this an item as unstarred
*
* This method marks an item as unstarred for a certain user.
*
* @param string $itemId The item id that can be retrieved from $this->listAll()
*
* @return boolean
*/
public function markAsUnstarred($itemId) {
$data = sprintf(
'i=%1$s&T=%2$s&r=%3$s&ac=edit',
$itemId, $this->_token,'user/-/state/com.google/starred'
);
$path = '/reader/api/0/edit-tag?client=-';
$host = 'www.google.com';
$response = $this->_httpPost($host, $path, $data);
if($response == null) return false;
return true;
}
} |
include_once 'ericmann-gReader-Library/greader.class.php';
class google_reader extends JDMReader
{
public function __construct()
{
}
public function connect($username, $password)
{
parent::__construct($username, $password);
}
// List a particular number of unread posts from the user's reading list
public function getStarred($limit) {
$gUrl = 'http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/starred';
$args = sprintf('n=%2$s&ck=%3$s&client=GoogleReaderDashboard', time() - (7*24*3600), $limit, time());
$data = $this->_httpGet($gUrl, $args);
$decoded_data = json_decode($data, true);
$feed_items = $decoded_data['items'];
return($feed_items);
}
/**
* Mark this an item as unstarred
*
* This method marks an item as unstarred for a certain user.
*
* @param string $itemId The item id that can be retrieved from $this->listAll()
*
* @return boolean
*/
public function markAsUnstarred($itemId) {
$data = sprintf(
'i=%1$s&T=%2$s&r=%3$s&ac=edit',
$itemId, $this->_token,'user/-/state/com.google/starred'
);
$path = '/reader/api/0/edit-tag?client=-';
$host = 'www.google.com';
$response = $this->_httpPost($host, $path, $data);
if($response == null) return false;
return true;
}
}
юзаем:
$this->load->library('google_reader');
$this->google_reader->connect('login@gmail.com','******');
if ($this->google_reader->loaded)
{
print_r($this->google_reader->getStarred(10));
} |
$this->load->library('google_reader');
$this->google_reader->connect('login@gmail.com','******');
if ($this->google_reader->loaded)
{
print_r($this->google_reader->getStarred(10));
}
CodeIgniter,
PHP,
Кодинх 
IAD
Warning: count(): Parameter must be an array or an object that implements Countable in
/var/www/html/wp-content/themes/amlet/archive.php on line
31