I want to get details about a plugin hosted on WordPress.org Repository by making a call to API at http://api.wordpress.org/plugins/info/1.0/
I have pasted below the code I used and the output. I am not good with PHP and just wanted to know the way to retrieve and output just one piece of information from the array such as Download count.
$payload = array(
'action' => 'plugin_information',
'request' => serialize(
(object)array(
'slug' => 'i-recommend-this',
'fields' => array(
'downloaded' => true,
'description' => false
)
)
)
);
$body = wp_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', array( 'body' => $payload) );
var_dump( unserialize($body['body']) );
This outputs data in below way:
object(stdClass)[320]
public 'name' => string 'I Recommend This' (length=16)
public 'slug' => string 'i-recommend-this' (length=16)
public 'version' => string '2.4.2' (length=5)
public 'author' => string '<a href="http://www.harishchouhan.com">Harish Chouhan</a>' (length=57)
public 'author_profile' => string 'http://profiles.wordpress.org/hchouhan' (length=38)
public 'contributors' =>
array
'hchouhan' => string 'http://profiles.wordpress.org/hchouhan' (length=38)
'dreamsonline' => string 'http://profiles.wordpress.org/dreamsonline' (length=42)
'dreamsmedia' => string 'http://profiles.wordpress.org/dreamsmedia' (length=41)
'Benoit "LeBen" Burgener' => string '' (length=0)
public 'requires' => string '3.3' (length=3)
public 'tested' => string '3.5.2' (length=5)
public 'compatibility' =>
array
'3.6' =>
array
'2.4.0' =>
array
...
'2.4.2' =>
array
...
public 'rating' => float 92.4
public 'num_ratings' => int 13
public 'downloaded' => int 7673
public 'last_updated' => string '2013-08-25' (length=10)
public 'added' => string '2012-04-25' (length=10)
public 'homepage' => string 'http://www.harishchouhan.com/personal-projects/i-recommend-this/' (length=64)
public 'sections' =>
array
'description' => string '<p>This plugin allows your visitors to simply like/recommend your posts instead of comment on it.</p>
<h4>This plugin includes</h4>
<ul>
<li>A counter to display the number of "like" and to vote.</li>
<li>A widget and a function to display the X most liked posts.</li>
<li>A preference pane with some options.</li>
<li>Saves Cookie as well as users IP address to disable voting on the same post again</li>
</ul>
<h4>Advanced Options</h4>
<ul>
<li>Hide count if count is zero</li>
<li>Set a default messages w'... (length=1694)
'installation' => string '<ol>
<li>Upload the directory <code>/i-recommend-this/</code> to the <code>/wp-content/plugins/</code> directory</li>
<li>Activate the plugin through the 'Plugins' menu in WordPress</li>
<li>Click on the Settings link below the plugin name on the plugins page</li>
</ol>
<p>To display the recomment/like link other than at the bottom of individual post, you would have to add below code in your template</p>
<pre><code><?php if( function_exists('dot_irecommendthis') ) dot_irecommendthis(); ?>'... (length=586)
'changelog' => string '<p>= 2.4.2
* Bug fix. Thanks to @mmaxim</p>
<p>= 2.4.1
* Fixed undefined index error.</p>
<p>= 2.4.0
* Added filter dot_irt_before_count to be able to allow custom content or icons before the count.</p>
<p>= 2.3.0
* Added option to hide count if count is zero
* Added option to disable saving of IP address in the database</p>
<p>= 2.2.0
* Added option to customize the link title. You can now remove the word recomment and add anything you like. Ideas suggested by Krystina Montemurro.</p>
<p>= 2.1.5
* Sup'... (length=2216)
'faq' => string '<p>Take a look at the <a href="http://www.dreamsonline.net/wordpress-plugins/i-recommend-this/">official "I Recommend This" FAQ</a>.</p>
<p>You can also visit the <a href="http://www.dreamsonline.net/wordpress-plugins/i-recommend-this/">support center</a> and start a discussion if needed.</p>' (length=294)
public 'download_link' => string 'http://downloads.wordpress.org/plugin/i-recommend-this.2.4.2.zip' (length=64)
public 'tags' =>
array
'dribbble-like' => string 'dribbble like' (length=13)
'heart' => string 'heart' (length=5)
'like' => string 'Like' (length=4)
'love' => string 'love' (length=4)
'post' => string 'Post' (length=4)
'rate' => string 'rate' (length=4)
'rating' => string 'rating' (length=6)
'recommend' => string 'recommend' (length=9)