public function getData()
{
$Cache_Lite = new Cache_Lite(parent::getCacheOptions());
$url = sprintf('https://readitlaterlist.com/v2/get?username=%s&password=%s&apikey=%s&count=%s&format=json', $this->config['username'], $this->config['password'], $this->config['apikey'], $this->config['total']);
$id = $url;
if ($data = $Cache_Lite->get($id)) {
$data = json_decode($data);
} else {
$Cache_Lite->get($id);
PubwichLog::log(2, Pubwich::_('Rebuilding cache for a Readitlater'));
PubwichLog::log(2, $this->url);
$data = file_get_contents($url);
$data = json_decode($data);
foreach ($data->list as $item) {
// Default value
$item->title = parse_url($item->url, PHP_URL_HOST);
// If check page title
if (!empty($this->config['getTitle'])) {
$file = @fopen($item->url, "r");
if ($file) {
$text = fread($file, 1024 * 3);
if (preg_match('/<title>(.*?)<\\/title>/is', $text, $found)) {
$item->title = $found[1];
}
}
}
}
// Write cache
$cacheWrite = $Cache_Lite->save(json_encode($data));
}
return $data->list;
}