Skip to content

Instantly share code, notes, and snippets.

@PeterBooker
Last active December 25, 2015 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeterBooker/7050407 to your computer and use it in GitHub Desktop.
Save PeterBooker/7050407 to your computer and use it in GitHub Desktop.
This gives an example of how to query the wordpress.org plugins API for data on all plugins.
<?php
/*
* Query the wordpress.org Plugins API
*/
$query = array(
'action' => 'query_plugins',
'request' => serialize(
(object) array(
'page' => 1,
'per_page' => 100,
'search' => '',
'fields' => array(
'sections' => false,
'homepage' => true,
'tested' => true,
'last_updated' => true,
'description' => false,
'downloaded' => true,
'downloadlink' => true,
'tags' => true
)
)
)
);
// Setup arguments for POST request.
$args = array(
'method' => 'POST',
'timeout' => 10,
'redirection' => 5,
'httpversion' => '1.1',
'blocking' => true,
'headers' => array(),
'body' => $query,
'cookies' => array(),
'sslverify' => false,
);
$response = wp_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', $args );
if ( ! is_wp_error( $response ) ) {
echo '<pre>';
print_r( unserialize( $response['body'] ) );
echo '</pre>';
} else {
echo '<pre>';
print_r( $response );
echo '</pre>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment