How can I retrive the usage of drupal by API?

Posted July 23, 2019 1.2k views

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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
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.
return $query;

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