Title: Error with PHP?
Last modified: August 21, 2016

---

# Error with PHP?

 *  Resolved [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/)
 * New to WordPress and PHP so I apologize if this is an easy one. Tried to implement
   the Kebo twitter into my html document with the following code and I got the 
   below error message:
 *  <div class=”content-wrap”>
    <?php $tweets = kebo_twitter_get_tweets(); ?> <?
   php $i = 0; ?> <?php foreach ($tweets as $tweet) : ?> <?php echo $tweet->text;?
   > <?php if ( ++$i == 10 ) break; ?> <?php endforeach; ?> </div>
 * Warning: Invalid argument supplied for foreach() in D:\Hosting\2780066\html\wp-
   content\themes\rapscallion\footer.php on line 41
 * Any help would be appreciated!
    Thanks.
 * [http://wordpress.org/plugins/kebo-twitter-feed/](http://wordpress.org/plugins/kebo-twitter-feed/)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/error-with-php/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/error-with-php/page/2/?output_format=md)

 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995326)
 * Hi pdaniel,
 * It is great to see that you are customising how the Tweets display on your website.
 * Looking at your code it does not look there are any PHP problems. It appears 
   that there is nothing in the $tweets variable. I will be updating the example
   code in the readme with improved code which checks if there is anything in $tweets
   first. Here is the code:
 *     ```
       <?php $tweets = kebo_twitter_get_tweets(); ?>
   
       <?php $i = 0; ?>
   
       <?php if (is_array($tweets)) : ?>
   
           <?php foreach ($tweets as $tweet) : ?>
   
               <?php echo $tweet->text; ?>
   
               <?php if (++$i == 10) break; ?>
   
           <?php endforeach; ?>
   
       <?php else : ?>
   
           <p>Sorry, no Tweets found.</p>
   
       <?php endif; ?>
       ```
   
 * The other problem is why are there no Tweets? If you look at the plugin options
   page under Settings -> Kebo Twitter, are there any messages displayed in the 
   error log?
 * Another thing to check, if you assign the Kebo Twitter Widget to a widget area,
   does it manage to display the Tweets?
 *  Thread Starter [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995344)
 * I don’t see any error messages from the settings page. It looks like I’m connected
   and no error messages in the log. I’ll try to add it to the widget area and see
   if that works. Thanks for the prompt response!
 * To enable us to display your Tweets you must connect your Twitter account to 
   our Twitter Application by clicking on the large ‘Connect to Twitter’ button 
   below.
    Connected to Twitter
 * Connected as @rapscallionbeer ✖
 * General Options
 * Feed Refresh Rate
 * Minutes. Should be between 1 and 30.
    This controls how frequently we update 
   the stored list of Tweets for display on your website.
 * Error Log
 * There is a chance that we may receive errors when making requests to Twitter,
   which will be displayed below. If errors are occuring consistently please check
   the key below to see if action is required.
    Date Code Message Good news, there
   have been no errors received from Twitter recently.
 *  Thread Starter [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995345)
 * I don’t see how I can add a widget to the page. I have activated the Kebo widget
   by moving the widget to the right side bar on the Widget page. What would be 
   the next step?
 * thanks.
 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995347)
 * Hi pdaniel,
 * That should do it, once the widget is in the right side bar area on the Widgets
   page, it should now be displaying on your website.
 * If the widget is set to Style List, it should display on your website either 
   a list of tweets or a message stating ‘Sorry, no Tweets were found.’ do either
   of these happen?
 * It seems the Plugin and Widget are correctly setup, so it should be displying
   Tweets on your website. Is that happening?
 *  Thread Starter [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995348)
 * it is set to style: list.
 * Here are the settings I have. I don’t see it on the web site. The site is customized
   some so I’m not sure if that has to do with anything.
 * Kebo Twitter Feed:
 * Title: Latest Tweet
    Style: List Theme: Light Number Of Tweets: 1
 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995352)
 * And still no luck displaying? Okay…
 * Then it suggests to me, it has never managed to get your Tweets.
 * I just checked the error log from my script which handles the OAuth requests 
   and there have been 0 errors in the last 24 hours. It might be possible that 
   your install has not actually made a request.
 * We can test this by checking what is inside $tweets, where you were trying your
   custom code could you please try this code:
 *     ```
       <?php $tweets = kebo_twitter_get_tweets(); ?>
   
       <?php print_r($tweets); ?>
       ```
   
 * ** note: If this is a production/live site, you might not want to do this as 
   it could output a huge amount of text onto the page, containing masses of Tweet
   data. **
 * Then have a look at the site and see what it outputs? If it outputs anything 
   can you paste that back here please?
 *  Thread Starter [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995353)
 * thanks. It is a live site unfortunately. I can try it later tonight. I’ll follow
   up after to let you know what I find. thanks again!
 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995355)
 * Ah no problem, you could also use a check for an administrator user, and only
   output it then (for your eyes only!). This code should do it:
 *     ```
       <?php
       // Check for an Admin user, then output $tweets
       if ( current_user_can('activate_plugins') ) {
           $tweets = kebo_twitter_get_tweets();
           print_r($tweets);
       }
       ?>
       ```
   
 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995435)
 * Hi pdaniel,
 * Did you have any luck outputting the Tweets? If not can I help troubleshoot the
   reason in any way?
 *  Thread Starter [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995436)
 * no, my computer was giving me fits last night. going to try today real quick.
   will let you know. thanks so much for the help.
 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995522)
 * Hi pdaniel,
 * I will close this as I haven’t heard anything back from you. Just let me know
   if you still need help, or have any other problems.
 * I believe the problem which was causing this has been resolved. I was sending
   GZIP’d data to all sites, without checking if they had the ability to inflate
   it once received. I now check for the relevant Accept-Encoding headers and responsd
   using GZIP if it is supported.
 *  Thread Starter [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995523)
 * Hi Peter – Actually this was on my list to get down. Let me give it another shot
   tonight based on your feedback and I’ll get back to you.
 * thanks!
 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995524)
 * Hi pdaniel,
 * No problem, ill keep an eye out.
 *  Thread Starter [pdaniel](https://wordpress.org/support/users/pdaniel/)
 * (@pdaniel)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995527)
 * Ok, it looks like I was able to pull back tweets when I added the code from your
   suggestion above. So, I then tried to code the custom tweet per the sample and
   I got the same error I did before..
 * Warning: Invalid argument supplied for foreach() in D:\Hosting\2780066\html\wp-
   content\themes\rapscallion\footer.php on line 41
 * Here’s the code..
 *  <div class=”content-wrap”>
    <?php $tweets = kebo_twitter_get_tweets(); ?> <?
   php $i = 0; ?> <?php foreach ($tweets as $tweet) : ?> <?php echo $tweet->text;?
   > <?php if ( ++$i == 10 ) break; ?> <?php endforeach; ?> </div>
 * Any suggestions? PHP is not my strong point.
 * thanks!
 *  Plugin Author [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * (@peterbooker)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-with-php/#post-3995528)
 * Hi pdaniel,
 * Would you be able to install this version of the plugin please: [http://peterbooker.com/kebo/kebo-twitter-feed.zip](http://peterbooker.com/kebo/kebo-twitter-feed.zip)
 * It will send me an email with the contents of the tweet data at two points: 1)
   when it first fetches it from the API and 2) when it trys to render the widget.
 * This will help me to track down what is going wrong with the process. Once it
   is installed refresh the page a few times with the widget up and I will post 
   back here with what I found out from the emails.

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/error-with-php/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/error-with-php/page/2/?output_format=md)

The topic ‘Error with PHP?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/kebo-twitter-feed_00aced.svg)
 * [Kebo Twitter Feed](https://wordpress.org/plugins/kebo-twitter-feed/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/kebo-twitter-feed/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/kebo-twitter-feed/)
 * [Active Topics](https://wordpress.org/support/plugin/kebo-twitter-feed/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/kebo-twitter-feed/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/kebo-twitter-feed/reviews/)

## Tags

 * [php-error](https://wordpress.org/support/topic-tag/php-error/)

 * 17 replies
 * 2 participants
 * Last reply from: [Peter Booker](https://wordpress.org/support/users/peterbooker/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/error-with-php/page/2/#post-3995537)
 * Status: resolved