logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
Updating class-snoopy.php widget to http.php

I have a twitter widget that uses class-snoopy.php which is now deprecated and I receive this message:

Notice: class-snoopy.php is deprecated since version 3.0! Use wp-includes/http.php instead.


So, I have updated the include to include http.php instead but I then get the error of:

Fatal error: Class 'Snoopy' not found in /home/path/to/backend/widgets/twitter.php on line 28


So, here is the area of code affected:

if ($tweet['lastcheck'] < (mktime() - 60)) {
$snoopy = new Snoopy;
$result = $snoopy->fetch($url);

// Check if any tweets were returned from Twitter API
if ($result) {
$twitterdata = json_decode($snoopy->results, true);


Line 28:

$snoopy = new Snoopy;


Obviously I'm using snoopy to fetch the tweets but since it is now changed to use http.php, I need to update this, but what to?

This question has been answered.

drew | 03/28/11 at 6:58am Edit


(2) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    03/28/11
    1:58pm
    Lew Ayotte says:

    since class Snoopy is deprecated and you should use WP Http, you won't be able to do a 'new Snoopy' without including the snoopy class. You need to do a "new WP_Http"...

    Here is a good blog post about using the WP Http API - http://planetozh.com/blog/2009/08/how-to-make-http-requests-with-wordpress/

  • avatar
    Last edited:
    03/28/11
    1:58pm
    yves vu says:

    Hi,

    WordPress 3.x update: you now need to explicitly include the class if you intend to use it, that is start by adding the following lines:

    Please follow 2 steps:
    Step1: if you don't include,please add code

    if( !class_exists( 'WP_Http' ) )
    include_once( ABSPATH . WPINC. '/class-http.php' );


    Step2:
    Change this code:
    if ($tweet['lastcheck'] < (mktime() - 60)) {

    $snoopy = new Snoopy;

    $result = $snoopy->fetch($url);



    // Check if any tweets were returned from Twitter API

    if ($result) {

    $twitterdata = json_decode($snoopy->results, true);


    To code:
    $request = new WP_Http;
    $result = $request->request($url);
    // Check if any tweets were returned from Twitter API

    if ($result) {

    $twitterdata = json_decode($result['body'], true);


    If this solutions is not ok .
    Please send email to me: yves.vu@gmail.com

    Cheers.

    Previous versions of this answer: 03/28/11 at 12:54pm

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.