Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2010
1,574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php
  2. /*
  3. Retrieve items from the plugin API
  4. */
  5. function get_api_data($per_page, $page)
  6. {
  7.     $fields = array(
  8.         'downloaded' => true,
  9.         'author' => false,
  10.         'author_profile' => false,
  11.         'contributors' => false,
  12.         'requires' => true,
  13.         'tested' => false,
  14.         'compatibility' => false,
  15.         'homepage' => false,
  16.         'description' => false,
  17.         'last_updated' => true,
  18.         'added' => true
  19.     );
  20.     $body = (object) array('browse' => 'new', 'page' => $page, 'per_page' => $per_page, 'fields' => $fields);
  21.     $post_data = array('action' => 'query_plugins', 'request' => serialize($body));
  22.  
  23.     $ch = curl_init();
  24.     curl_setopt($ch, CURLOPT_POST, true);
  25.     curl_setopt($ch, CURLOPT_URL, 'http://api.wordpress.org/plugins/info/1.0/');
  26.     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  27.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  28.     $return = curl_exec($ch);
  29.     curl_close($ch);
  30.  
  31.     return unserialize($return);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement