[wp-hackers] Checking plugin version

Otto otto at ottodestruct.com
Sat Sep 22 15:55:02 UTC 2012


The core code uses a GET on that, actually. It's not as complex as the
plugin API is.

-Otto


On Sat, Sep 22, 2012 at 10:11 AM, Chris McCoy <chris at lod.com> wrote:
> Thanks for the info on that what about the version for the update api?
>
> Recently I was doing a check for the latest version from a shell script
>
> curl -s http://api.wordpress.org/core/version-check/1.6/ | sed -e
> 's/.*s:7:"current";s:5:"//;s/".*//'
>
> which currently would print 3.4.2
>
> does the version check allow post?
>
>
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com
> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Otto
> Sent: Saturday, September 22, 2012 8:02 AM
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Checking plugin version
>
> On Sat, Sep 22, 2012 at 6:50 AM, Chris McCoy <chris at lod.com> wrote:
>> To get the plugin ver you can do something like this
>>
>>     $url = 'http://api.wordpress.org/plugins/info/1.0/wordpress-seo/';
>>
>>     $ch = curl_init();
>>     curl_setopt($ch, CURLOPT_URL, $url);
>>     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>>     $result = curl_exec($ch);
>>     curl_close($ch);
>>
>>     $result = unserialize($result);
>>     echo $result->version;
>
>
> While that works, I cannot guarantee that it will continue to work in the
> future. It's not the way the WordPress core itself uses to talk to the API
> server.
>
> You should be doing an HTTP POST to:
> http://api.wordpress.org/plugins/info/1.0/
>
> The parameters in the body of the POST for the plugin info request should
> be:
> 'action' = 'plugin_information'
> and
> 'request' = PHP serialized version of array('slug'=>'whatever')
>
> If you want to not get certain parts of the request (like all the sections
> stuff from the readme), you can add an optional fields parameter to that
> request array, like so:
> array( 'slug'=>'whatever', 'fields' => array('sections' => false) )
>
> That would make it not return the "sections" section in the response.
>
> -Otto
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list