TweetPHP: Display tweets on your website using PHP

If you’ve ever wanted to display your latest Twitter tweets on a website, TweetPHP lets you do that using PHP. TweetPHP is a rewrite of my old Twitter RSS feed parser, which stopped working when Twitter phased out their v1 API.

Features

  • Works with Twitter API v1.1
  • Tweets are cached to avoid exceeding Twitter’s API request rate limits
  • A fallback is provided in case the twitter feed fails to load
  • Retweets and @replies can be optionally ignored
  • A configuration parameter allows you to specify how many tweets are displayed
  • Dates can optionally be displayed in “Twitter style”, e.g. “12 minutes ago”
  • You can customize the HTML that wraps your tweets, tweet status and meta information

Download

TweetPHP is available on Github

Usage

To interact with Twitter’s API you will need to create an API KEY, which you can create at: https://dev.twitter.com/apps

After creating your API Key you will need to take note of following values: “Consumer key”, “Consumer secret”, “Access token”, “Access token secret”

Those values can be passed as options to the class constructor, along with the Twitter screen name you wish to query:

require_once('TweetPHP.php');

$TweetPHP = new TweetPHP(array(
  'consumer_key'              => 'xxxxxxxxxxxxxxxxxxxxx',
  'consumer_secret'           => 'xxxxxxxxxxxxxxxxxxxxx',
  'access_token'              => 'xxxxxxxxxxxxxxxxxxxxx',
  'access_token_secret'       => 'xxxxxxxxxxxxxxxxxxxxx',
  'twitter_screen_name'       => 'yourusername'
));

Then you can display the results like so:

echo $TweetPHP->get_tweet_list();

Options

Options can be overridden by passing an array of key/value pairs to the class constructor. At a minimum you must set the consumer_key, consumer_secret, access_token, access_token_secret and twitter_screen_name options, as shown above.

Here is a full list of options, and their default values:

'consumer_key'          => '',
'consumer_secret'       => '',
'access_token'          => '',
'access_token_secret'   => '',
'twitter_screen_name'   => '',
'cache_file'            => dirname(__FILE__) . '/cache/twitter.txt', // Where on the server to save the cached formatted tweets
'cache_file_raw'        => dirname(__FILE__) . '/cache/twitter-array.txt', // Where on the server to save the cached raw tweets
'cachetime'             => 60 * 60, // Seconds to cache feed (1 hour).
'tweets_to_display'     => 10, // How many tweets to fetch
'ignore_replies'        => true, // Ignore @replies
'ignore_retweets'       => true, // Ignore retweets
'twitter_style_dates'   => false, // Use twitter style dates e.g. 2 hours ago
'twitter_date_text'     => array('seconds', 'minutes', 'about', 'hour', 'ago'),
'date_format'           => '%I:%M %p %b %d%O', // The defult date format e.g. 12:08 PM Jun 12th. See: http://php.net/manual/en/function.strftime.php
'date_lang'             => null, // Language for date e.g. 'fr_FR'. See: http://php.net/manual/en/function.setlocale.php
'format'                => 'html', // Can be 'html' or 'array'
'twitter_wrap_open'     => '<h2>Latest tweets</h2><ul id="twitter">',
'twitter_wrap_close'    => '</ul>',
'tweet_wrap_open'       => '<li><span class="status">',
'meta_wrap_open'        => '</span><span class="meta"> ',
'meta_wrap_close'       => '</span>',
'tweet_wrap_close'      => '</li>',
'error_message'         => 'Oops, our twitter feed is unavailable right now.',
'error_link_text'       => 'Follow us on Twitter',
'debug'                 => false

Caching

Caching is employed because Twitter rate limits how many times their feeds can be accessed per hour.

When the user timeline is first loaded, the resultant HTML list is saved as a text file on your web server. The default location for this file is: cache/twitter.txt

You can change this file path by setting the cache_file option. For example, to set a path from your root public directory try:

$_SERVER['DOCUMENT_ROOT'] . '/path/to/my/cache/dir/filename.txt'

Debugging

If you are experiencing problems using the plugin please set the debug option to true. This will set PHP’s error reporting level to E_ALL, and will also display a debugging report.

Here are a few tips to help you solve common configuration issues:

tmhOAuth response code: 0

If your debugging report shows the error “tmhOAuth response code: 0″, you can find out more about this error message in the tmhOAuth github README. Dario also offers this solution: “My server didn’t like the the two __DIR__ constants in the tmhOAuth.php file, hard-coded them and it all works now.”

unserialize error

If you receive the PHP warning “[function.unserialize]: Error at offset 0 of 49 bytes”, it might be the case that you have magic quotes enabled in your PHP configuration.

Credits

- Feed parsing uses Matt Harris’ tmhOAuth
- Hashtag/username parsing uses Mike Cochrane’s twitter-text-php

67 thoughts on “TweetPHP: Display tweets on your website using PHP

  1. M says:

    I keep getting the following error:
    Fatal error: Call to a member function get_tweet_list() on a non-object in /home/../../TweetPHP.php on line 221

    line 221:
    echo $TweetPHP->get_tweet_list();

  2. Jonathan says:

    @M That error message is telling you that the variable $TweetPHP is not an object. Before line 221 have you created an instance of the TweetPHP class and assigned it to a variable named $TweetPHP?

    e.g. $TweetPHP = new TweetPHP( etc…

  3. Terry Upton says:

    Hi Jonathan,

    I have tried to setup and install this new version but with no joy so far.
    I have taken a similar approach to the original script but I am only getting blank results not even erros.

    I have created the API key and entered the consumer_key, consumer_secret, access_token, access_token_secret and the twitter_screen_name

    I have created the 2 txt documents for the cache with writable permissions and also included the script on the page.

    include(‘/twitter-new/TweetPHP.php’);

    I have then called get_tweet_list(); ?> within the page.

    But as I say nothing shows, just blank (like an error) but no error reported.

    Any input or insight you can offer please?

    Thanks.

  4. Terry Upton says:

    Actually I have sorted it all now. Crisis over.
    Great script Jonathan.

    Thanks again!

  5. Jonathan says:

    @Terry Those are my favourite sort of bugs: the ones that fix themselves! Pleased to hear you got it working.

  6. Terry Upton says:

    Hi Jonathan,

    Seem to have ran into an issue that perhaps you can shed some light on or explain? I ma not sure if it is a bug or my settings….

    So I have two cache files inside the twitter folder and have linked to them in the options section. The cache time is set to 60*60 but the twitter feed isn’t loading the cache instead the error message is displayed (as per the error_message and errror_link_text). The last tweet was from yesterday. Could this be a reate limits issue (although I thought the cache file would stop this) or have I set something up incorrectly?

    Thanks in advance.

  7. nle says:

    @Terry Upton

    How about explaining what you did to sort it out. I also have the same problem. I tried just to replace the previous version of the script, entering all the keys, etc. but I get no output.

  8. Robert says:

    Echoing nle’s comment.

    I have included the script on my page. I have tested to ensure that it is being included OK (by putting some text in the file which duly appears on the page, and doesn’t break the page) but when I try to create a new instance of TweetPHP and then echo it, it breaks the page – the content before the script appears, the Twitter feed and content which should follow the script doesn’t.

    I am assuming that at the end of the script (picking up on your reply to M) I should create a new instance by inserting the code as follows (with the values inserted, of course, as they have been within the class constructor):

    $TweetPHP = new TweetPHP(array(
    ‘consumer_key’ => ”,
    ‘consumer_secret’ => ”,
    ‘access_token’ => ”,
    ‘access_token_secret’ => ”,
    ‘twitter_screen_name’ => ”
    ));

    echo $TweetPHP->get_tweet_list();

    But each time I do this I get this effect of the content ‘breaking’.

    Jonathan, I VERY much appreciate your efforts, and folks like you.

  9. Jonathan says:

    @Robert It sounds as if a PHP error is being thrown, but that PHP errors are suppressed, so you are not seeing the error message. If that’s the case, you may be able to enable PHP error reporting by adding the following line before your TweetPHP code:

    < ?php error_reporting(E_ALL); ?>

    Let me know what error message is displayed.

  10. Jonathan says:

    @Terry The simplest way to test that the cache file is being loaded is to manually edit the file (just put some obvious test text in it, something like “testing…”), and see if TweetPHP displays your test text. If not, then it didn’t locate the cache_file, and has fetched the tweets anew.

    I’m thinking that I might need to add a debugging option for TweetPHP that displays information about what is happening behind the scenes, which ought to make it easier to figure out what’s happening in cases like yours.

  11. Jonathan says:

    I have added a new option: debug, which accepts values true|false. When set to true, PHP error reporting will be set to E_ALL, and get_tweet_list will render an HTML list of debugging information. The public methods get_debug_list() and get_debug_array() can also be used to fetch the debugging information.

  12. Robert says:

    Jonathan,

    I have tried inserting the error reporting instruction before the TweetPHP code but to no avail – still nothing showing after the code is called, and no error being reported. I have also downloaded the new version with the debugging option from Github, set the option to ‘true’, but again to no avail. I do know that the ‘include’ instruction is working as if I insert the word ‘testing’ at the start of the TweetPHP file it shows up on the page. Including the file without calling an instance of TweetPHP doesn’t break the page (as I suppose he constructor isn’t doing anything without further instruction). But when I try to call a new instance of TweetPHP, then the page breaks. It’s obviously something stupid I am doing as others are making the code work.

    So to recap, I am replicating the TweetPHP file, then inserting the various code items from my Twitter application. I have created two blank .txt files and referenced them among the options in TweetPHP. I have included TweetPHP in my page. And then I have tried to create a new instance of TweetPHP, and echo it, at the end of the TweetPHP code.

    One thing I do notice from the TweetPHP code as downloaded, is the following two lines:
    require_once “lib/tmhOAuth/tmhOAuth.php”;
    require_once “lib/twitter-text-php/lib/Twitter/Autolink.php”;

    To my untrained eye it looks as though these addresses are incomplete, if used from my site. Am I supposed to do something with these, or is that taken care of somewhere else in your coding?

    I have managed to get someone else’s PHP Twitter parser working so am not desperate, but I think your program, with all the options laid out, is so much more elegant!

    Again, many thanks for your efforts and attention.

  13. Jonathan says:

    @Robert I think you’re right that the includes are likely causing problems. The relative file paths seem to not be resolving correctly with certain server configurations.

    I have updated TweetPHP so that the method of including files is more robust, and improved the method of determining the path at which to cache files.

    The PHP error reporting level is now set before any includes, so hopefully if the includes are failing then this should now be apparent.

    Can you please download the latest Master from github and try it out.

  14. nle says:

    Hi, first I want to thank you for your work! I really appreciate it, and it is really nice that you keep your script updated when Twitter changes api, etc.

    I got it to show the tweets now, but I have two problems.

    - I find it hard to set an URL from root. I use this in combination with Stacey CMS, and I want to use the default cache directory located under “/app/_cache/”, but the script always thinks it is in whatever folder the php file is.

    - I want to use my local name of the months (norwegian). In previous version I could use “setlocale(LC_ALL, ‘no_NO’);” in the top of the PHP file, but that does not work now – I still get english month names.

    Any solutions to this problem?

  15. Jonathan says:

    @nle You should be able to define a path to the cache directory like so:

    $_SERVER['DOCUMENT_ROOT'] . ‘/app/_cache/filename.txt’

    As for the date language, I’m surprised to hear that setlocale used to work for you, since I don’t think it affects PHP’s date() function? In any case, I have modified TweetPHP’s date formatting to use strftime() which respects the locale set using setlocale.

    You can set the locale using the new date_lang option e.g.

    ‘date_lang’ => ‘no_NO’

    If you were previously using a custom date format, you’ll need to rework it for strftime. See: http://php.net/manual/en/function.strftime.php

    Also you can now override the default “Twitter style date” text using the new twitter_date_text option e.g.

    ‘twitter_date_text’ => array(‘seconds’, ‘minutes’, ‘about’, ‘hour’, ‘ago’)

    Let me know if these new language options are behaving the way you expect.

  16. nle says:

    Thank you.

    You know way more than me about PHP, but setting the locale worked for me in the previous version. Why it worked, I don’t know, but I probably did alot of googling/research, and managed to get it to work the last time.

    Anyways, everything seems to work now, except for one weird thing. It looks like the timezone is wrong when I use it in combination with Stacey. I don’t know why, because it works normally when I used it “alone” (pure download from github).

    I fixed the timezone issue by adding “date_default_timezone_set(‘Europe/Oslo’);” in the top of the file.

    Again, thank you for your work and swift response! :)

  17. Jonathan says:

    @nle Thank sofr bringing the time zone thing to my attention. I’ve updated TweetPHP to display dates in the tweeter’s local time (i.e. the same date that is shown on Twitter.)

  18. Neal says:

    TweetPHP is a fantastic! Thank you for your hard work.

    I’ve come across a strange issue: a tweet is missing. I’ve checked the cashed files and reset them several times, but I’m missing a tweet.

    Here is the beta: http://ias.jbrowning.biz/ and here are the original tweets: https://twitter.com/interasset

    If you look closely, this tweet from July 15 is missing:
    “@KNSeafreight To Open 60,000 sq ft cross dock #warehouse in UK http://ow.ly/mLRZ7

    No errors are thrown.

    Any ideas why this tweet is overlooked?

  19. Jonathan says:

    @Neal You need to set the ignore_replies option to false. Because that tweet begins with @username, Twitter considers it to be an @reply, and in most cases you don’t want to display those.

  20. Neal says:

    Outstanding! Thank you.

    TweetPHP has saved my bacon. Hmmm, bacon. :)

  21. Jonathan says:

    I’m wondering: would anyone be interested in me extending TweetPHP to make different sorts of queries, such as searching by hashtag? Or an option to display avatars next to tweets?

  22. Anthony says:

    I’m getting this error,what’s up with this one?

    A PHP Error was encountered
    Severity: Notice
    Message: unserialize() [function.unserialize]: Error at offset 0 of 49 bytes
    Filename: tweet-php/TweetPHP.php
    Line Number: 90

  23. DogBear says:

    Hi Jonathan. Struggling to get the feed to come through. Ive changed the text in the txt file and that displayed so it looks as though paths are ok but im not getting the feed through. Ive got 777 permissions set on the cache folder. Error checking turned on shows this:

    Cache expiration timestamp: 1378032149
    Cache file timestamp: 1378031748
    Cache file doesn’t exist or is older than cachetime.
    Fetching fresh tweets using Twitter API.
    tmhOAuth response code: 0
    Bad tmhOAuth response code.
    No tweets were found. error_message will be displayed.

    Any ideas where I might be going wrong? Thanks

  24. Shannon says:

    Is there any chance you might be revisiting TwitterTicker to make it work with Twitter’s API or enabling a ticker or scrolling capibility in TweetPHP? Thank you so much for all your fine work :)

  25. Jonathan says:

    @Anthony If you send me the cache.txt file that PHP is trying to unserialize, I can take a look. By default it’s stored at /cache/twitter.txt. I’m guessing, but one possibility is that PHP is configured with magic quotes turned on? See: http://stackoverflow.com/questions/4149030/php-unserialize-error-at-offset-works-on-some-servers-not-others

  26. Jonathan says:

    @DogBear See https://github.com/themattharris/tmhOAuth for more on that particular error code. I’ll modify TweetPHP to output the tmhOAuth error message, instead of just the response code. That might assist in debugging.

  27. Jonathan says:

    @Shannon I’m not sure what you mean by “revisiting” TwitterTicker? TwitterTicker isn’t something I’m familiar with at all! I don’t have any plans to add ticker/scroll to TweetPHP – its job is just to pull tweets using the Twitter API, and render them as vanilla HTML. What you choose to do with it after that is up to you, but certainly it would be possible with a sprinkling of CSS and JS to create a ticker of the sort you’re describing.

  28. Shannon says:

    Thank you for your reply – the maker must have built upon your work as you’re included in the ReadMe file. I did figure out the ticker issue and a sprinkle of CSS and JS did do the trick :) Thank you again and keep up the good work!

  29. Jonathan says:

    @Shannon Ah right, they must have been using my old RSS parsing script, which stopped working when Twitter phased out timeline RSS feeds. I’m pleased to hear you got it working.

  30. Yves says:

    Just tried this script. I have consumer key, secret etc.

    The only thing the script does is showing the text from the /cache/twitter.txt. No tweets are loaded/shown/written…

    Any ideas?
    http://www.letzgo.net/tweets.php
    http://www.letzgo.net/phpinfo.php

  31. DogBear says:

    Hi Johnathan. Problem solved. For anyone having the same problem I’ll explain:

    I needed to update the default paths set for curl_cainfo & curl_capath in tmhOAuth.php with the exact path of the cacert.pem file. E.g. – ‘./tweetphp/lib/tmhOAuth/cacert.pem’

    Thanks for pointing me in the right direction. Good man!

  32. Jonathan says:

    @Yves Turn on TweetPHP’s debugging mode and see what error messages are shown.

  33. Perumal says:

    Hi,
    i have been download the script from [ https://github.com/jnicol/tweet-php ] and given the ‘consumer_key’, ‘consumer_secret’,’access_token’,’access_token_secret’,’twitter_screen_name’ information’s correctly but the page didn’t display anything..
    it has display as blank page…

    kindly guide me..

    Regards,
    S.Perumal
    Chennai

  34. Jonathan says:

    @ Perumal Turn on TweetPHP’s debugging mode and see what error messages are shown.

  35. Perumal says:

    @Jonathan

    There is no error in my page, there is a blank(empty) page in my website, kindly check the below web link also..

    http://mysummary.me/for_appln/twitter/tweet-php-master/TweetPHP.php

    this is my parked source web directory…

  36. Jonathan says:

    @Perumal Showing me a link to the TweetPHP class file doesn’t help me to help you. Like I said, set TweetPHP’s debug option to true to see what’s going wrong. If you share the debugging output with me then I may be able to assist.

  37. Perumal says:

    Hello Jonathan,

    Thank you for your answer and to spent much more valuable time for me, could you possible to give me the full source code..!
    because i have been tried many times(ways) so kindly give me full execution compressed files..
    that is useful for validate my mistake also…

    please give me full execution files for twitter feeds display on my website..

    Thanks and advance
    Perumal

  38. Zahid Habib says:

    When I run it says “Oops, our twitter feed is unavailable right now”

    Whats wrong?

  39. Jonathan says:

    @Zahid Turn on TweetPHP’s debugging mode and see what error messages are shown.

  40. Alex says:

    Hello,

    Been struggling to get it to work:

    Notice: unserialize() [function.unserialize]: Error at offset 0 of 49 bytes in /home/xxx/domains/xxxx.com/public_html/twitter/TweetPHP.php on line 90
    Cache expiration timestamp: 1384468207
    Cache file timestamp: 1384471130
    Cache file is newer than cachetime.
    This is the default twitter.txt cache file.

    Any idea?

    Thanks,
    Alex

  41. Jonathan says:

    @Alex See my reply to Anthony above, about magic quotes.

  42. Alex says:

    Thanks Jonathan!

    I missed that point. Maybe a good idea to put a note at the top, I was miles away from suspecting this, though I am a programmer wannabie :-)

    Alex

  43. Dario says:

    Hi Jonathan,

    I’m getting a similar error as the error @DogBear got:

    Cache expiration timestamp: 1385338940
    Cache file timestamp: 0
    Cache file doesn’t exist or is older than cachetime.
    Fetching fresh tweets using Twitter API.
    tmhOAuth response code: 0
    Bad tmhOAuth response code.
    No tweets were found. error_message will be displayed.

    I’ve had a look at tmhOAuth but simply can’t figure out what’s gone wrong…

    My Twitter app settings are as follows:
    Access level: Read, write, and direct messages
    Sign in with Twitter: Yes
    Callback URL: None
    @Anywhere: the domain that I’m adding the script to.

    Any idea of what’s up with my setup?

    Thanks

  44. Dario says:

    Please disregard my earlier comment, I figured out what was wrong.

    My server didn’t like the the two __DIR__ constants in the tmhOAuth.php file, hard-coded them and it all works now.

    Thanks for this great little tool.

  45. Jonathan says:

    @Dario That’s a good find. I think I’ll add a Troubleshooting section to this post and include your tip.

  46. Joey says:

    Hi, Thanks for this but i am getting an error saying ” Oops, our twitter feed is unavailable right now. Follow us on Twitter”

    In my file i have a simple code that goes like this;
    “require_once(‘TweetPHP.php’);

    $TweetPHP = new TweetPHP();

    //dumb tweet feed here
    echo $TweetPHP->get_tweet_list();”

    What i’m i not doing right?

  47. Jonathan says:

    @Joey Have you enabled TweetPHP’s debug option? What is the debugging output?

  48. Peter says:

    Hi Jonathan,

    I’ve finally taken the time to update the code on our site to work with the new API (again, based on your code) and the one thing I can’t figure out is how to display the display_url instead of url.

    I seem to remember having to strong-arm it into the code with the previous version, but now that it isn’t based on RSS I’m not sure what to do.

    Has anyone else solved this one, or are there a lot of t.co addresses on people’s feeds?

    Thanks and keep up the awesome work!

  49. Hey there, using this on our site, but just getting a message saying “This is the default twitter.txt cache file.”

    Not even getting the twitter_wrap_open variable displaying a Tweets at the beginning or anything.

    See it on MedRevise – I’ve altered the twitter.txt file to say a message “coming soon” whilst I fix it.

    C

  50. Medical dude says:

    No worries, it was the magic quotes thing. Sorted. Thanks.

    What’s an easy way to reset the cache? IE, after making changes?

  51. Bart says:

    Good morning! I’ve been trying to use this plugin, but can’t seem to get it working. The cache .txt files can’t be found, because the path to these files is wrong.

    The path is created as this:
    Warning: fopen(/home/bart747/domains/bveenhof.nl/public_html/portfolio./cache/twitter.txt) [function.fopen]: failed to open stream: No such file or directory in /home/bart747/domains/bveenhof.nl/public_html/portfolio/TweetPHP.php on line 153

    The problem is this: portfolio. There’s a dot after portfolio, which is why the path is incorrect. I can’t seem to find out where this dot is coming from though… Any thoughts on where it could come from?

    Thanks in advance!

  52. Bart says:

    magically started working! :) Well, sort of. Getting this error right now:

    Cache expiration timestamp: 1391588499
    Cache file timestamp: 1391522282
    Cache file doesn’t exist or is older than cachetime.
    Fetching fresh tweets using Twitter API.
    tmhOAuth response code: 200
    No tweets were found. error_message will be displayed.

    I’ll try to mess around more :)

  53. Bart says:

    Sorry for spamming this page, but the previous problem has sorta solved itself too. Although i still have this error:

    Cache expiration timestamp: 1391588499
    Cache file timestamp: 1391522282
    Cache file doesn’t exist or is older than cachetime.

    The tweets are not loaded. However, when i delete the cache .txt files the Tweets work fine. There’s a huge error though because it can’t locate the .txt files anymore :(

  54. Marty says:

    Hello. I am trying to get this to work on my website, but when ever I call the TweetPHP function, everything seems to stop working and just not load.
    I am requiring the php file and after that calling the function (passing the options into it) like it says. But cant seem to make it work.
    I have turned on error reporting, but am also not getting any errors displayed.

  55. Al says:

    I have tried for a few hours to get this working. I created a test script http://www.gallerychurchbaltimore.com/twitter/twitter.php
    turning on the debug I only see my twitter.txt cache file.
    I cannot seem to pull the latest tweets down using the script. I have actually tried putting all the options into my test script also with same results.

    my debug output is
    Cache expiration timestamp: 1392319597
    Cache file timestamp: 1392322781
    Cache file is newer than cachetime.
    HI Al This is the default twitter.txt cache file.

  56. Jonathan says:

    @Marty If your page just dies then that’s probably due to a PHP error. Turn on PHP error reporting so you can see the error message. You may need to view the source of the rendered page to see the message.

  57. Jonathan says:

    @Al To figure out why your tweets are not being pulled from Twitter, you should delete the two cache .txt files. The next time the script runs it will try to fetch your timeline from Twitter, and the debug messages might give a clue why that transaction is failing.

    The two most likely reasons are:

    1) You haven’t correctly created your Twitter API key, or populated TweetPHP with those values (see the usage section of this article). I would expect to see a thmOAuth error message in that case.

    2) TweetPHP is able to fetch your timeline from Twitter (it will display them on your site), but is unable to write the tweets to the cache. You’ll know if that’s happening because the cache files will not be recreated after you delete them.

  58. gundam says:

    thx you ^^v
    I’m succeded using this..but share my story first
    * i tried make app (failed). I must enter my phone
    * I type my phone in setting and got charge bout $1 (nah.. not big deal)..
    * I supposed is should respond to twitter accepted my phone but isn’t?!? anyway skip this and i return to the app.. and succed make the app!!
    * in https://apps.twitter.com/app/xxxx (xx:number), click API Keys
    * generated API Keys (dont forget about permision)
    * API key&API secret goes to consumer_key&consumer_secret
    * access token&secret is same
    * delete cache..

    the problem? I don’t see any. hope everything is fine

  59. Martyn says:

    Can you give me some guidance around the “twitter_date_text” option? I’d quite like it to say for example “3 days ago”. It seems it only does the “X ago” type text if it’s within the one day. Is that right? Can it be changed?

    Not a problem if not, I was just wondering.

  60. Jonathan says:

    @Martyn Yes, the “twitter style dates” will start showing an actual date when a tweet is a day old, which mimics the behaviour on Twitter. If you want to change that you could edit the date parsing logic which starts at line 184. There are currently switch cases for seconds, minutes and hours, and you’d need to change the default case to calculate the number of elapsed days and display that instead of the date.

  61. gundam says:

    I found something related to time. Since the detail are to long.. I posted on my blog. you can check on my blog link http://adapani.blogspot.com/2014/03/tweetphp-why-time-is-invalid.html

  62. José Luis says:

    Hi Jonathan. I’m using your script, and I’m wondering if it’s possible to automatically ‘refresh’ the tweets or, perhaps, include a button to do the task. Can you point me in the right direction? Thank you!!!

  63. Jonathan says:

    @José If you set the cachetime configuration option to a lower value, like 60 seconds, then the cache will purge and refresh every minute. This requires a page refresh obviously.

  64. gundam says:

    @jose try use cron.. is better than page refresh..
    but remember to ‘log’ every refresh you made on cron..

  65. Mark says:

    Hey man, for me it isn’t working.

    I get this error :

    PHP Notice: unserialize(): Error at offset 0 of 49 bytes in twitter/TweetPHP.php on line 90

  66. Jonathan says:

    @Mark That error message is explained in the post.

  67. How to make it work in WordPress? Thanks!

Comments are closed.