Twitter Not Displaying on Site Home Page
Hello, I'm conducting work on a Perch website for a client who has utilized the product for a year to this point. Unfortunately, Perch itself is new to me, so I'm constantly looking for answers in the forums and documentation to fill in gaps in my knowledge. However, I am at a point where I cannot come up with additional ideas to troubleshoot the issue I'm confronted with due to the circumstances by which I operate the site's support from a remote location, and only have access to a few folders through a drive accessed by WebDAV.
The site had been running an old version of Perch, and the company requested that I install twitter support for them. By reading the documentation for that however, I discovered that the version of Perch was too early to run the Perch 2 version of Twitter. With that in mind, and discovering that they had sufficient MySQL and PHP version in the Diagnostic panel, I suggested they upgrade to Perch 3 so that we could roll out the Perch_twitter app. That took some doing, but I thought I had upgraded them properly as they are back to the status-quo with the new UI at this point.
However, in installing Perch_Twitter there were complications, in that the system spat out a sequence of errors for an employee at their office who was supposed to manage the website in-house when they went to complete the last few steps of the Twitter installation process barring the 'add to webpage' part. Their description of the problem was that it displayed out multiple lines of error code when they selected 'Get Tweets', but that it somehow managed to retrieve the tweets afterwards.
Notice: Trying to get property of non-object in C:\inetpub\dev\admin\addons\apps\perch_twitter\PerchTwitter.class.php on line 163
I had chalked this up to the database having issues with the newly installed Twitter app. But since the tweets 'appeared' to be populated, I presumed everything was fine and carried on with the installation instructions. It wasn't until things did not operate properly in the last step of adding the tweets to the webpage that I became curious and opened the PerchTwitter.class.php to see what line 163 was.
public function get_tweet_html($tweet)
{
$API = new PerchAPI(1.0, 'perch_twitter');
$HTTP = $API->get('HTTPClient');
$response = $HTTP->get('https://publish.twitter.com/oembed?omit_script=true&url=https://twitter.com/Interior/status/'.$tweet->id_str);
$item = PerchUtil::json_safe_decode($response);
if (!isset($item->error)) {
return $item->html;
}
return -1;
The line in question turned out to be the 'return $item->html;'.
Which may have become relevant when I went to add the twitter section to a selected web page within a div using:
<?php
perch_twitter_get_latest();
perch_twitter_widget_js();
?>
Which only injected: <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> into the webpage at this point. So now I'm curious if there was some tie-up with regards to getting the html for the tweets in question and all the entries for them are entirely blank. The reason why I'm 'guessing' at this point, is that while the website administration page is accessible to me, and the FTP folders hosted for the website, I do not have direct access to the database upon which it was installed and must ask our client to look into the database themselves, so my hypothesis is based purely on the details I can glean from the code and the resulting lack of content displayed.
My basic diagnostic has the following, if it helps debug what is going on. If additional information is required, I will provide the full diagnostic:
Perch: 3.0.11, PHP: 5.6.20, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: WINNT, cgi-fcgi
Installed apps: content (3.0.11), assets (3.0.11), categories (3.0.11), perch_blog (5.6.1), perch_twitter (4.0)
App runtimes: <?php $apps_list = [ 'perch_blog', 'perch_twitter', ];
PERCH_LOGINPATH: /admin
PERCH_PATH: C:\inetpub\dev\admin
PERCH_CORE: C:\inetpub\dev\admin\core
PERCH_RESFILEPATH: C:\inetpub\dev\admin\resources
Image manipulation: GD
PHP limits: Max upload 10M, Max POST 10M, Memory: 128M, Total max file upload: 10M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
REQUEST_URI: /admin/core/settings/diagnostics/
DOCUMENT_ROOT: C:\inetpub\dev
HTTP_HOST: www.website.ca
What should I, or the person managing my client's twitter account be doing to get these tweets to display on the page? Is it possible they forgot to select an option in setting up the Twitter options for their account? Or should I be contacting the person managing the database to verify that the database table's column for tweet html is entirely blank? Thanks in advance for any advice that you can give me.
I am going to get the database administrator at the client's office to look into the perch2_twitter table to verify that the database column is empty. If anyone has any other suggestions of ideas I should pursue to resolve my issue with integrating the Twitter app in this website, please let me know. I do not know enough about the internal functionality of the Perch_Twitter app to understand why it would not be able to retrieve the html-wrapped tweets, but would be able to acquire the raw text of those tweets.
Any ideas at all would be appreciated.
Are those tweets protected?
No, I just checked the twitter account of my clients, and they have 90 tweets, and no notification of their account being set to 'protected' when accessing anonymously.. Would there be another reason why the perch2_twitter_tweets table's column tweetHTML in the database would be set to NULL while tweetText was retrieved properly?
The fact that it retrieved something, rather than nothing, suggests that the OAuth process went correctly, but the fact that it is omitting that critical component leaves me baffled. Is there some other information I should acquire to try to diagnose this problem before doing something as a shot in the dark, like dropping the contents of perch2_twitter tables out of the database and trying to get the app reinstalled?
Can you give an example tweet ID?
Go watch the tutorial videos.
Hey Drew, sorry it took me so long to get back to you. Holidays and all.
I'm unsure if you mean 'id' as in the numerical tag that twitter uses in its urls to bring up particular tweets in a timeline, or something separate within the perch_twitter database tables.
One of the tweets we pulled in seems to be referred to as "941370057946304512" on Twitter. Does that sound like the sort of number you would be looking for? I am also looking into the database to see if there might be a different number you might be looking for. I will let you know when I have some more information from the on-site database in case the ID in the system is significantly different.
Thanks for your help Drew, I was not expecting the installation of this twitter application to be quite this complicated.
EDIT: I checked the database, and that ID I previously provided is listed under the 'tweetTwitterID' column.
Yes, that's what I'm after.
Let me know if that tells you something useful, or if you think I should just go through the process of trying to reinstall perch_twitter on my client's system.
Hey Drew,
Haven't heard back with regards to this issue so I'm going to go through the process of having my client uninstall the database component of the perch_twitter app so that we can attempt to reinstall it again. If you have any particular details that you would suggest I look into before or after this process please let me know. I am still unsure of what I should be on the lookout for to solve my client's issue.
That tweet is embedding fine for me here, so short of further information I'm not sure what to suggest.
I'll get you the complete diagnostic file. And I'll hold off on the re-installation for a little while longer. I just hope this gives you sufficient information to help diagnose this issue.
That doesn't really reveal too much more, to be honest. Is your development server on Windows too? I'm wondering if that's a factor.
It is on a Windows server. It has been that way for almost a year now and we haven't had major complications until trying to install the perch_twitter app to embed a feed into it.
I don't know what to suggest, unfortunately.
That is unfortunate. If you have any possible additional ideas of things that I should check or inquire after please let me know.
Did you try removing the tables and letting it reinstall? Would only take about 30 seconds to do.
Do you mean just perch_twitter2 ? Or some other tables in addition to that?
Which tables should I ask the database admin to truncate/drop? Or better, whether I should truncate the contents or drop the tables entirely?
Do you have a table called
perch_twitter2
?If so, that's not come from us.
I may be paraphrasing. As I said previously, I do not have the database in front of me due to my remote support role. I think I meant perch2_twitter, now that I look around for that information.
I've been thinking more on the steps involved in creating this twitter app. One of which involved setting a 'callback url', I was curious if you might know Drew, what would happen if the callback URL was set incorrectly, or not at all? Would it refuse to communicate with the perch Twitter app, or would it not send html encoded tweets like I've been seeing here?
I know, it's a bit of a shot in the dark, but there are only a few possible points where data was entered, and now I'm wondering if something might have been incorrectly configured during the twitter dev/OAuth process. It's still probably wisest to do a drop and reinstall at this point, but the more I think about the steps, that is the only point I am unsure about.
I think this would probably quite quick to troubleshoot and fix if you could sit down in front of it.