Twitter App not displaying Tweets

  • Hi,


    I'm having an issue with getting the Twitter App working and Tweets displaying on my site.


    I've tried it on a production server as well and no joy, but for the purposes of this thread, I will keep to my development XAMPP set-up (windows).


    I have looked at multiple threads on the forum and some have gotten me further than I was, but cutting a long story short, this morning I decided to cut my losses once more and reinstall the Perch Twitter App. I have entered all the clients details into the Twitter App and (using the advice from http://forum.grabaperch.com/fo…-app-authentication-error) added the extra elements to the Callback URL, which had previously removed some errors.


    However, on initial set-up I received the error:


    Quote

    Notice: Trying to get property of non-object in C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php on line 163

    along with some other header issues, which, looking at another thread are caused by the above.


    Once past these errors, all the Tweets were pulled in. If I select 'Get Tweets' again, I get no errors and debug shows me nothing.


    I can Force reauthentication and it comes back to the admin not a problem.


    It's almost as if the Tweets are just not being rendered to the screen.

    In my code, I am just using the standard call:


    PHP
    1. <?php
    2. perch_twitter_get_latest();
    3. perch_twitter_widget_js();
    4. ?>


    Which calls the template tweet.html. I can add content to the template such as:


    Code
    1. <perch:twitter id="tweetHTML" encode="false" />Why does this not display

    and on my page I can see:


    Why does this not displayWhy does this not displayWhy does this not display


    which is what I would expect, with the standard install returning the last three tweets, i.e. cycling through 3 times.


    I've tried a custom call:



    PHP
    1. <?php
    2. perch_twitter_get_latest([
    3. 'twitter_id' => '@KLSSupportUK',
    4. 'type' => 'mine',
    5. 'count' => 3,
    6. 'exclude_replies' => 1,
    7. 'template' => 'twitter/tweet.html',
    8. ]);
    9. ?>


    and still no joy.


    All very odd and highly frustrating. This app used to just work out of the box not a problem but dare I say, ever since Twitter changed their policy, this app just never seems to work correctly for me on local or production servers.


    I've added perchDebug and there is nothing coming up on the output either.


    Below is my diagnostics.


    Any help greatly appreciated, surely cannot be only person having these issues.


    Thanks,


    Andy

  • One other item.


    It seems to make no difference at all if I have the code:

    PHP
    1. <?php perch_twitter_widget_js(); ?>

    on my page. I presume this is just how the tweet is rendered, so if I had my own specific template, this would be obsolete anyway.



    Just grasping at why the template is shown, but the 'tweet' content is not. The only item in my template is


    Code
    1. <perch:twitter id="tweetHTML" encode="true" />

    This displays nothing, but all tweets are in admin etc.

  • Hi. What's the output of the debug message when you load the page with the twitter function on it? The line that will help you should look something like:


    Code
    1. `SELECT * FROM perch3_twitter_tweets WHERE tweetType='mine' AND tweetAccount='@ACCOUNT' AND tweetIsReply=0 ORDER BY tweetDate DESC LIMIT 3`


    Is it returning any records?

  • My debug returns


    SQL
    1. SELECT * FROM perch3_twitter_tweets WHERE tweetType='mine' AND tweetAccount='@KLSSupportUK' ORDER BY tweetDate DESC LIMIT 1

    So the only difference I can see is the:


    AND tweetIsReply=0


    LIMIT 1 element


    I will look into what these elements are doing or how you can adjust them.

  • If I'm correct in thinking, the LIMIT statement would 'limit' the records returned, yet, I can see that the template is called and loops 3times, so I presume this element has nothing to do with it.


    I also presume the tweetIsReply item would be driven via Perch itself to navigate through the tweets and pullback just the required items, i.e. only my tweets, include replies, other peoples tweets etc.


    Ahh, yes, slight apologies. I'm pulling tweets back in multiple pages and I have used different calls to retreive the tweets, thinking it might be something to do with this.

    The above SQL statement was a result from the call:


    PHP
    1. <?php
    2.     perch_twitter_get_latest(array(
    3.     'twitter_id'=>'@KLSSupportUK',
    4. 'type'=>'mine',
    5. 'count'=>1
    6. ));
    7. ?>


    So if I go back to the standard call of:


    PHP
    1. <?php
    2. perch_twitter_get_latest();
    3. perch_twitter_widget_js();
    4. ?>


    My debug becomes:


    SQL
    1. SELECT * FROM perch3_twitter_tweets WHERE tweetType='mine' AND tweetAccount='@KLSSupportUK' ORDER BY tweetDate DESC LIMIT 3


    So again, just the tweetIsReply element missing.


    This does not display any records, but if I add some text to the template, I can see on the page that it has looped through 3 times, so it's finding the 'tweet.html' template, but just not rendering the tweets themselves.


    Any ideas ?


    Thanks, really appreciated.

  • On the far right of that line is a light blue tab with a number or `null` in it. That's the number of records retrieved by Perch with your page's function call. If it is `null` then there's an issue with your twitter app as it isn't pulling anything from the database. I'd suggest going through the installation again and check all the steps carefully. Also check the twitter tables have set up correctly.


    The other issue when you click "get Tweets" in the admin page is probably a limit on API calls your app is making. Twitter is STRICT!

  • My light blue tad has '3' in it, as expected.


    I've already reinstalled the twitter app once and I've even got a new copy (download) in-case there had been some update or corruption on download. I've even tried a different users credentials on Twitter to see if I can display other tweets.


    Really at a loss here, as it all seems ok, but just not rendering the retrieved tweets.

  • It's just really odd, I can 'Get Tweets' and I get the green bar with all tweets updated, no errors. I can go into the perch twitter settings and force re-authentication and it brings me back to the site fine, no errors. The DB has the tweets within it, so I would now presume, the strict bit of Twitter has happened and now it's just an issue with Perch rendering them to the screen.

  • Do you have access to the database? If so, is the perch3_twitter_tweets table installed and filled with entries? Perhaps emptying that table and getting the tweets again would help clear the blockage.


    The other thing you can try is to echo the function out to the actual page. Just to rule out the template causing problems.


    Other than that I am at a loss and will leave it for the experts!

  • Yes, the perch3_twitter_tweets table has all the entries in there, so that's not the issue.


    Ok, so I emptied the table. Went back into Perch and reauthenticated the App, which was fine, then when I go to Tweets and hit 'Get Tweets', I get a number of errors.


    Quote

    Notice: Trying to get property of non-object in C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php on line 163

    This error repeats itself a number of times...I presume the amount of tweets it's pulled down.


    Quote

    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\lib\PerchUtil.class.php on line 1405

    The above, which I presume is die to the previous error and then lastly...


    Quote

    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\inc\top.php on line 17

    which again, I presume is due to the first one, just having the same item called in a different file.


    So, dealing with my first error, if I look at the file PerchTwitter.class.php we get on line 163:


    Code
    1. if (!isset($item->error)) {
    2. return $item->html; <--- THIS IS LINE 163
    3. }


    I had found this post but no resolution, same problem though - http://forum.grabaperch.com/fo…playing-on-site-home-page


    Just a thought, it's not something as daft as windows using forward slashes rather than backslashes ?


    Grasping at straws here.


    I will upload everything to the proper server (this is currently on XAMPP on windows) to see if it works there. STill, there must be loads of people working on local copies (XAMPP) on a PC.

  • Hmm, interestingly, when I put a new copy onto the live server (temp domain), it doesn't get past the twitter authentication. At the top of the page I get the message "There was an error".


    Debug shows me:


    Code
    1. Array
    2. (
    3. [type] => 2
    4. [message] => Cannot modify header information - headers already sent by (output started at /home/klssupportuk/public_html/admin/addons/apps/perch_twitter/modes/settings.pre.php:59)
    5. [file] => /home/klssupportuk/public_html/admin/core/inc/top.php
    6. [line] => 17
    7. )

    which is a tad odd......

  • This is getting so frustrating.


    I decided to delete the 'Twitter App' and rebuild it.


    I gave the app the actual site url, but the callback is for my locally hosted version with the additional item route to the settings:


    Quote

    http://[mylocaldomain]/admin/addons/apps/perch_twitter/settings/

    New App Authenticates fine...yay.


    But as soon as I go to retrieve Tweets I get ALL the errors mentioned above, so something is definitely not right, especially if there is a known bug in the Perch Twitter App that requires this additional routing to the callbackURL. Surely other people are finding this. Maybe they are just not using the Twitter App ? Might have to look at some alternative.


    Usual errors when pressing 'Get Tweets':

    Quote

    Notice: Trying to get property of non-object in C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php on line 163


    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\lib\PerchUtil.class.php on line 1405


    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\inc\top.php on line 17


    The perch3_twitter_tweets table gets updated with all the tweets and I can see them in the Admin (Listing Tweets page), so the app has downloaded and worked, so it MUST be perch side.


    The DEBUG shows:

    Code
    1. Array
    2. (
    3. [type] => 2
    4. [message] => Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163)
    5. [file] => C:\KDL-Projects\Open\kdl_kls\www\admin\core\inc\top.php
    6. [line] => 17
    7. )

    which points to this mysterious issue around line 163, but all this has is:

    Code
    1. if (!isset($item->error)) {
    2.     return $item->html;
    3. }



    If I press 'Get Tweets' again (for second time), the errors disappear, but still no display.

  • OK MAYBE GETTING SOMEWHERE.


    If I clear the perch3_twitter_tweets table and remove the below code from PerchTwitter.class.php (line 162 - 166):

    Code
    1. if (!isset($item->error)) {
    2. return $item->html;
    3. }
    4. return -1;

    Then press 'Get Tweets', the tweets import without error and I can see the raw html on the site !!!.

    It's something !!!!!!


    So, the Million Dollar Question is, why does the above code trigger all these issues ? and what could I try to resolve it.

  • OK MAYBE GETTING SOMEWHERE.


    If I clear the perch3_twitter_tweets table and remove the below code from PerchTwitter.class.php (line 162 - 166):

    Code
    1. if (!isset($item->error)) {
    2. return $item->html;
    3. }
    4. return -1;

    Then press 'Get Tweets', the tweets import without error and I can see the raw html on the site !!!.

    It's something !!!!!!


    So, the Million Dollar Question is, why does the above code trigger all these issues ? and what could I try to resolve it.

  • Hi Drew,


    Removing the @ from the 'Your Twitter username' in the perch twitter settings page, still produces all of the aforementioned errors. It's still failing at this line 163 item within PerchTwitter.class.php.


    I will try going back to using a custom call for the rendering of the tweets, as this was the only place that HAD used the @KLSupportUK name, but I cannot see this being any part of the issue.

  • ergrge


    Yes, as suspected, I have tried all permutations and still the above line 163 error.


    That is, I have used:


    addons/apps/perch_twitter/settings/


    Your Twitter username (required): @KLSSupportUK and KLSSupportUK


    with:


    PHP
    1. <?php
    2.     perch_twitter_get_latest(array(
    3.         'twitter_id'=>'KLSSupportUK',
    4.         'type'=>'mine',
    5.         'count'=>3
    6.     ));
    7. ?>


    PHP
    1. <?php
    2. perch_twitter_get_latest(array(
    3. 'twitter_id'=>'@KLSSupportUK',
    4. 'type'=>'mine',
    5. 'count'=>3
    6. ));
    7. ?>


    PHP
    1. <?php
    2.     perch_twitter_get_latest();
    3.     perch_twitter_widget_js();
    4. ?>


    The only thing that starts to allow the displaying of the tweets is the removal of the code around stated line 163 in PerchTwitter.class.php.


    The setup is authorising, bringing down tweets with no error anymore (when code removed), so it must be something to do with:


    Code
    1. return $item->html;


    failing, as this, I presume is allowing the tweet to be rendered in html format.