Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement