Comments (10)
Try replacing the script in userrss.php with the following script (also located here where it will be simpler to copy / paste):
<?php
/***********************************************************************************************
* Tweetledee - Incredibly easy access to Twitter data
* userrss.php -- User timeline results formatted as a RSS feed
* Version: 0.4.1
* Copyright 2014 Christopher Simpkins
* MIT License
************************************************************************************************/
/*-----------------------------------------------------------------------------------------------
==> Instructions:
- place the tweetledee directory in the public facing directory on your web server (frequently public_html)
- Access the default user timeline feed (count = 25, includes both RT's & replies) at the following URL:
e.g. http://<yourdomain>/tweetledee/userrss.php
==> User Timeline RSS feed parameters:
- 'c' - specify a tweet count (range 1 - 200, default = 25)
e.g. http://<yourdomain>/tweetledee/userrss.php?c=100
- 'user' - specify the Twitter user whose timeline you would like to retrieve (default = account associated with access token)
e.g. http://<yourdomain>/tweetledee/userrss.php?user=cooluser
- 'xrt' - exclude retweets (1=true, default = false)
e.g. http://<yourdomain>/tweetledee/userrss.php?xrt=1
- 'xrp' - exclude replies (1=true, default = false)
e.g. http://<yourdomain>/tweetledee/userrss.php?xrp=1
- 'cache_interval' - specify the duration of the cache interval in seconds (default = 90sec)
--------------------------------------------------------------------------------------------------*/
/*******************************************************************
* Debugging Flag
********************************************************************/
$TLD_DEBUG = 0;
if ($TLD_DEBUG == 1){
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
}
/*******************************************************************
* Includes
********************************************************************/
// Matt Harris' Twitter OAuth library
require 'tldlib/tmhOAuth.php';
require 'tldlib/tmhUtilities.php';
// include user keys
require 'tldlib/keys/tweetledee_keys.php';
// include Geoff Smith's utility functions
require 'tldlib/tldUtilities.php';
// include Christian Varga's twitter cache
require 'tldlib/tldCache.php';
/*******************************************************************
* Defaults
********************************************************************/
$count = 25; //default tweet number = 25
$include_retweets = true; //default to include retweets
$exclude_replies = false; //default to include replies
$screen_name = '';
$cache_interval = 90; // default cache interval = 90 seconds
/*******************************************************************
* Parameters
* - can pass via URL to web server
* - or as a parameter at the command line
********************************************************************/
// Command line parameter definitions //
if (defined('STDIN')) {
// check whether arguments were passed, if not there is no need to attempt to check the array
if (isset($argv)){
$shortopts = "c:";
$longopts = array(
"xrt",
"xrp",
"user:",
);
$params = getopt($shortopts, $longopts);
if (isset($params['c'])){
if ($params['c'] > 0 && $params['c'] <= 200)
$count = $params['c']; //assign to the count variable
}
if (isset($params['xrt'])){
$include_retweets = false;
}
if (isset($params['xrp'])){
$exclude_replies = true;
}
if (isset($params['user'])){
$screen_name = $params['user'];
}
if (isset($params['cache_interval'])){
$cache_interval = $params['cache_interval'];
}
}
}
// Web server URL parameter definitions //
else {
// c = tweet count ( possible range 1 - 200 tweets, else default = 25)
if (isset($_GET["c"])){
if ($_GET["c"] > 0 && $_GET["c"] <= 200){
$count = $_GET["c"];
}
}
// xrt = exclude retweets from the timeline ( possible values: 1=true, else false)
if (isset($_GET["xrt"])){
if ($_GET["xrt"] == 1){
$include_retweets = false;
}
}
// xrp = exclude replies from the timeline (possible values: 1=true, else false)
if (isset($_GET["xrp"])){
if ($_GET["xrp"] == 1){
$exclude_replies = true;
}
}
// user = Twitter screen name for the user timeline that the user is requesting (default = their own, possible values = any other Twitter user name)
if (isset($_GET["user"])){
$screen_name = $_GET["user"];
}
// cache_interval = the amount of time to keep the cached file
if (isset($_GET["cache_interval"])){
$cache_interval = $_GET["cache_interval"];
}
} // end else block
/*******************************************************************
* OAuth
********************************************************************/
$tldCache = new tldCache(array(
'consumer_key' => $my_consumer_key,
'consumer_secret' => $my_consumer_secret,
'user_token' => $my_access_token,
'user_secret' => $my_access_token_secret,
'curl_ssl_verifypeer' => false
), $cache_interval);
// request the user information
$data = $tldCache->auth_request();
// Parse information from response
$twitterName = $data['screen_name'];
$fullName = $data['name'];
$twitterAvatarUrl = $data['profile_image_url'];
if ( $screen_name == '' ) $screen_name = $data['screen_name'];
/*******************************************************************
* Request
********************************************************************/
$userTimelineObj = $tldCache->user_request(array(
'url' => '1.1/statuses/user_timeline',
'params' => array(
'include_entities' => true,
'count' => $count,
'exclude_replies' => $exclude_replies,
'include_rts' => $include_retweets,
'screen_name' => $screen_name,
)
));
// concatenate the URL for the atom href link
if (defined('STDIN')) {
$thequery = $_SERVER['PHP_SELF'];
} else {
$thequery = $_SERVER['PHP_SELF'] .'?'. urlencode($_SERVER['QUERY_STRING']);
}
// Start the output
header("Content-Type: application/rss+xml");
header("Content-type: text/xml; charset=utf-8");
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="<?php echo $my_domain ?><?php echo $thequery ?>" rel="self" type="application/rss+xml" />
<lastBuildDate><?php echo date(DATE_RSS); ?></lastBuildDate>
<language>en</language>
<title>Twitter user timeline feed for <?php echo $screen_name; ?></title>
<description>Twitter user timeline updates for <?php echo $screen_name; ?></description>
<link>http://www.twitter.com/<?php echo $screen_name; ?></link>
<ttl>960</ttl>
<generator>Tweetledee</generator>
<category>Personal</category>
<image>
<title>Twitter user timeline feed for <?php echo $screen_name; ?></title>
<link>http://www.twitter.com/<?php echo $screen_name; ?></link>
<url><?php echo $twitterAvatarUrl ?></url>
</image>
<?php foreach ($userTimelineObj as $currentitem) : ?>
<item>
<?php
$parsedTweet = tmhUtilities::entify_with_options(
objectToArray($currentitem),
array(
'target' => 'blank',
)
);
if (isset($currentitem['retweeted_status'])) :
$avatar = $currentitem['retweeted_status']['user']['profile_image_url'];
$rt = ' [<em style="font-size:smaller;">Retweeted by ' . $currentitem['user']['name'] . ' <a href=\'http://twitter.com/' . $currentitem['user']['screen_name'] . '\'>@' . $currentitem['user']['screen_name'] . '</a></em>]';
$tweeter = $currentitem['retweeted_status']['user']['screen_name'];
$fullname = $currentitem['retweeted_status']['user']['name'];
$tweetTitle = $currentitem['retweeted_status']['text'];
else :
$avatar = $currentitem['user']['profile_image_url'];
$rt = '';
$tweeter = $currentitem['user']['screen_name'];
$fullname = $currentitem['user']['name'];
$tweetTitle = $currentitem['text'];
endif;
?>
<title> <?php echo $tweetTitle; ?> </title>
<pubDate><?php echo reformatDate($currentitem['created_at']); ?></pubDate>
<link>https://twitter.com/<?php echo $screen_name ?>/statuses/<?php echo $currentitem['id_str']; ?></link>
<guid isPermaLink='false'><?php echo $currentitem['id_str']; ?></guid>
<description>
<![CDATA[
<div style='float:left;margin: 0 6px 6px 0;'>
<a href='https://twitter.com/<?php echo $screen_name ?>/statuses/<?php echo $currentitem['id_str']; ?>' border=0 target='blank'>
<img src='<?php echo $avatar; ?>' border=0 />
</a>
</div>
<strong><?php echo $fullname; ?></strong> <a href='https://twitter.com/<?php echo $tweeter; ?>' target='blank'>@<?php echo $tweeter;?></a><?php echo $rt ?><br />
<?php echo $parsedTweet; ?>
]]>
</description>
</item>
<?php endforeach; ?>
</channel>
</rss>
Let me know if that solves the problem. It should remove the author and open/close brackets at the beginning of the tweet.
from tweetledee.
Thanks for this. I have now uploaded the script and see how it works. I wanted to ask, what is the difference between the cached and non-cached version. This version seams to be instant, so I am a little unsure there.
If I wanted this edited script on the non-cached version what would I need to do?
from tweetledee.
what is the difference between the cached and non-cached version
The cached version saves the tweet results for a period of time and displays the cached/saved version to your visitors rather than communicating with the Twitter API each time that someone visits the page. The main reason for this is that Twitter has an API rate limit in place and if you exceed the limit, the API locks your application account out for a brief period (~10 - 15 mins). This will occur when the visits to your Twitter stream page are in excess of the rate limit. You cannot obtain new API results (i.e. pull in new tweets to the page) during this lockout period. The caching mechanism prevents this as long as you (1) don't reduce the cache time; (2) don't use more than one instance of Tweetledee - the number of visits is additive across all applications on your Twitter application account. The cache time can be adjusted with a URL parameter in each of the cached script versions. Another benefit of caching (and primary benefit for your readers!) is that the page will load much faster for all visitors who do not initiate the communication with the Twitter API because the results are saved locally on your web server. At most one visitor per cache period will initiate the cache process, the rest receive a much more rapid display of previously cached results. The downside to this approach is that they are not 'realtime' tweet streams. Unless you have a very low volume website, Twitter does not allow you to broadcast realtime tweet results after the API changes that occurred ~ one year ago. If you were developing something for your own use to view your tweets, you could probably get away with using the noncached version but for any production sites, I would recommend against it. I exceeded the rate limits during local testing of the code...
Twitter does offer Twitter widgets(I think this is what they are called?) which may allow for this, but you are constrained to the format that they provide. The html is available through your Twitter account if you'd like to give that a try.
Here are the details on Tweetledee caching from the documentation. It goes into more detail about the rate limits and caching intervals that are used.
If I wanted this edited script on the non-cached version what would I need to do
The change is in this line https://github.com/chrissimpkins/tweetledee/blob/master/tweetledee/userrss.php#L212 where
<title>[<?php echo $tweeter; ?>] <?php echo $tweetTitle; ?> </title>
is changed to:
<title> <?php echo $tweetTitle; ?> </title>
You can make the same change in this location of the noncached version of the script and then access it at the URL http://[sitename]/tweetledee/userrss_nocache.php
from tweetledee.
Note also that the text in that area of the script are HTML formatted and you could also add anything else that you want to routinely display in the tweet results.
e.g.:
<title> Cool Stuff: <?php echo $tweetTitle; ?> </title>
prints:
Cool Stuff: [tweet message]
where [tweet message] is the text content of the tweet. The text that you removed was just a PHP variable that holds your user account name. It was formatted in open/close brackets.
from tweetledee.
Wow.. thanks for the information.
You really did your research on this. I will let you know how I get on. From the sounds of things I shall stick with the cached version. It seams to be pretty real-time from where I am looking at it. It might not be to the millisecond, but I can say it's within seconds.
I truly appreciate your help.
from tweetledee.
my pleasure. good luck!
On Jul 14, 2015, at 4:54 PM, ayyelo [email protected] wrote:
Wow.. thanks for the information.
You really did your research on this. I will let you know how I get on. From the sounds of things I shall stick with the cached version. It seams to be pretty real-time from where I am looking at it. It might not be to the millisecond, but I can say it's within seconds.
I truly appreciate your help.
—
Reply to this email directly or view it on GitHub.
from tweetledee.
Hi Chris,
Sorry to be pestering you again. I received my final tweet and it appeared on Facebook. Unfortunately, it appeared in the wrong format. You can see the tweet here.
https://www.facebook.com/CRSRecruitment.eu?fref=ts
Unfortunately the Facebook post reads, 'Glen Lindsay on Twitter', ideally it should not read this. How would I edit this. It also display the logo of the company. I would want the image to be something related to a job. I could probably make something for this.
The twitter feed reads perfectly, this can be found here, https://twitter.com/CRSeuRECRUIT.
Can you please help me so I can get this resolved.
Thanks again for all your support, I could have not done this without your assistance and I am truly appreciated.
Kind regards,
from tweetledee.
This looks like a Facebook related issue. Facebook is formatting your Twitter feed with the following format:
[Twitter username] on Twitter:
"[tweet text]"
Twitter.com | By [Twitter username]
The image is your Twitter account avatar. I think that the only way to modify this is to change the respective settings in the Twitter account so that it pulls a different image in and modifies your name to your company name. You might check Facebook documentation for more info about this. I don't use Facebook and am not familiar with their Twitter feed support.
from tweetledee.
They don't have much twitter feed support. I needed to create an RSS feed via your script and import is through Hootsuit to publish it directly to the page. Unfortunately however, the formatting is all wrong. I am going to play around with Hootsuit to see if I can find a solution.
Thanks again for all your help and support.
from tweetledee.
does IFTTT have a RSS to Facebook script? be worth looking into this
from tweetledee.
Related Issues (20)
- 280 characters HOT 2
- media content privileged over profile images? HOT 1
- hashtag entity replacements generating error HOT 1
- Show all images of tweet HOT 3
- Quoting another tweet should have the other tweet included in feed HOT 10
- Fight duplication ! HOT 4
- Add a comparison with RSS-Bridge HOT 4
- Factorize parameters processing
- Factorize debug flag management
- Set author in RSS entry according to twitter handle
- "user_timeline connection failure" when I use searchrss.php HOT 4
- The *_nocache embarks a bug HOT 1
- This tweet breaks tweetledee HOT 2
- Use https for avatar img src? HOT 2
- Undefined index: type in parametersProcessing.php HOT 2
- Latest redesign of Twitter makes retweets impossible to open HOT 1
- No images are shown HOT 1
- User with a username that end with underscore not work properly HOT 4
- Tweet breaks LibXML
- Tweetledee is broken HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tweetledee.