
Untitled
By: a guest on
Jul 2nd, 2010 | syntax:
PHP | size: 0.99 KB | hits: 300 | expires: Never
<?php
/*
Retrieve items from the plugin API
*/
function get_api_data($per_page, $page)
{
$fields = array(
'downloaded' => true,
'author' => false,
'author_profile' => false,
'contributors' => false,
'requires' => true,
'tested' => false,
'compatibility' => false,
'homepage' => false,
'description' => false,
'last_updated' => true,
'added' => true
);
$body = (object) array('browse' => 'new', 'page' => $page, 'per_page' => $per_page, 'fields' => $fields);
$post_data = array('action' => 'query_plugins', 'request' => serialize($body));
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_URL, 'http://api.wordpress.org/plugins/info/1.0/');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($ch);
curl_close($ch);
return unserialize($return);
}