Created
May 29, 2012 23:07
-
-
Save trepmal/2831344 to your computer and use it in GitHub Desktop.
Stand-alone WordPress.org plugin api access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Stand-alone WordPress.org plugin api access | |
$url = 'http://api.wordpress.org/plugins/info/1.0/'; | |
$fields = array( | |
'action' => 'query_plugins', | |
'request' => serialize( (object) array( | |
'author' => 'trepmal', | |
//'search' => 'howdy', | |
// 'page' => 1, | |
// 'per_page' => 20 | |
) ) | |
); | |
//url-ify the data for the POST | |
$fields_string = array(); | |
foreach( $fields as $key => $value) { | |
$fields_string[] .= "{$key}={$value}"; | |
} | |
$fields_string = implode( '&', $fields_string ); | |
//open connection | |
$ch = curl_init(); | |
//set the url, number of POST vars, POST data | |
curl_setopt( $ch, CURLOPT_URL, $url ); | |
curl_setopt( $ch, CURLOPT_POST, count( $fields ) ); | |
curl_setopt( $ch, CURLOPT_POSTFIELDS, $fields_string ); | |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); | |
//execute post | |
$result = curl_exec($ch); | |
//close connection | |
curl_close($ch); | |
$result = unserialize( $result ); | |
//die( '<pre>'. print_r($result, true) .'</pre>' ); | |
echo '<ul>'; | |
foreach ( $result->plugins as $r ){ | |
echo '<li>'. $r->name .'</li>'; | |
} | |
echo '</ul>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment