Horje
Updating class-snoopy.php widget to http.php - Wordpress Solution
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?

Solution - 1

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 - [[LINK href="http://planetozh.com/blog/2009/08/how-to-make-http-requests-with-wordpress/"]]http://planetozh.com/blog/2009/08/how-to-make-http-requests-with-wordpress/[[/LINK]]


Solution - 2

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: [email protected] Cheers.





Wordpress

Related
Need Widget to display new users - Wordpress Solution Need Widget to display new users - Wordpress Solution
Further customizing Flickr integration on Autofocus+ Pro Theme? - Wordpress Solution Further customizing Flickr integration on Autofocus+ Pro Theme? - Wordpress Solution
Subscribe to Categories - Wordpress Solution Subscribe to Categories - Wordpress Solution
Load Javascript & CSS Only on Add New Post & Add New Page Screen? - Wordpress Solution Load Javascript & CSS Only on Add New Post & Add New Page Screen? - Wordpress Solution
Custom Walker Class - wp_nav_menu() - Wordpress Solution Custom Walker Class - wp_nav_menu() - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7