I have this code that works.
PHP Code:
<?
if (isset($_GET['days'])) {
$num_days = (int)$_GET['days'];
} else {
$num_days = 10;
}
if (isset($_GET['wanted'])) {
$channel_id = 17;
} else {
$channel_id = 17;
}
$channel_id = '17","14","15","16","19","2347499","2359981';
// Path to the vBulletin 5 folder.
// '.' indicates current directory where the .htaccess file resides.
$vbpath = '..';
define('CSRF_PROTECTION', false);
require_once($vbpath . '/includes/vb5/autoloader.php');
vB5_Autoloader::register($vbpath);
vB5_Frontend_Application::init('config.php');
$api = Api_InterfaceAbstract::instance();
$search_json = '{"channel":["'.$channel_id.'"],"starter_only":1,"date":{"from":"'.$num_days.'"},"sort":{"lastcontent":"desc"},"view":"","exclude_type":["vBForum_PrivateMessage"]}';
$search_json = '{ "last":{"from":"7"}, "view":"topic","starter_only":"1", "sort":{"lastcontent":"desc"}, "channel":["17","14","15","16","19","2347499","2359981"] }';
$threads = vB_Api::instanceInternal('search')->getInitialResults($search_json, 30, 1);
$i = 0;
$thread_returns = array();
foreach ($threads['results'] as $tid => $thread_details) {
$i++;
$thread_returns['results'][$i] = array(
'title' => $thread_details['content']['title'],
'publishdate' => $thread_details['content']['publishdate'],
'channeltitle' => $thread_details['content']['channeltitle'],
'userid' => $thread_details['content']['userid'],
'description' => $thread_details['content']['description'],
'authorname' => $thread_details['content']['authorname'],
'uniqueid' => $thread_details['content']['nodeid']
);
$thread_returns['results'][$i]['postlink'] = vB5_Route::buildUrl(
$thread_details['routeid'] . '|fullurl',
array(
'nodeid' => $thread_details['nodeid'],
'title' => $thread_details['title']
)
);
}
$thread_returns['totalRecords'] = count($thread_returns['results']);
$thread_returns['searchJSON'] = $search_json;
$thread_returns['days'] = $num_days;
if ($thread_returns['totalRecords'] > 0) {
header('Content-Type: application/json');
echo json_encode($thread_returns);
}
?>
It display latest updated posts on my frontpage
https://www.zoopet.com
I want to get latest text and latest date from the post. Is there any $thread_details['content']['lastpostdescriptioin'] or something like that.