How can I retrive the usage of drupal by API?

July 23, 2019 154 views
DigitalOcean Drupal API

How can I retrive the usage of drupal by API?

I didn't find related API.

That mean, I can't get the usage by API?

1 comment
1 Answer

/**

  • Custom content function.
  • Set beginning and end dates, retrieve posts from database
  • saved in that time period.
  • @return
  • A result set of the targeted posts. */ function currentpostscontents(){ //Get today's date. $today = getdate(); //Calculate the date a week ago. $starttime = mktime(0, 0, 0,$today['mon'],($today['mday'] - 7), $today['year']); //Get all posts from one week ago to the present. $endtime = time();

//Use Database API to retrieve current posts.
$query = dbselect('node', 'n')
->fields('n', array('nid', 'title', 'created'))
->condition('status', 1) //Published.
->condition('created', array($start
time, $end_time), 'BETWEEN')
->orderBy('created', 'DESC') //Most recent first.
->execute();
return $query;

}
(Remember not to include the closing ?> in your code.)

Have another answer? Share your knowledge.