Hi,
I am working my way through Abraham’s twitteroauth lib for php and seem to be getting somewhere but then taking 2 steps backwards.
Here is my code as is:-
<html>
<head>
<title>Twitter Client example using PHP library - viralpatel.net</title>
<style>
body {
font-family: sans-serif;
font-size: 12px;
}
#update {
height: 90px;
width: 500px;
background-color: #EFEFEF;
margin-bottom: 5px;
padding: 5 5 5 5;
}
#update #left {
float:left;
display: inline;
padding-right: 7px;
}
#update .user {
font-weight: bold;
color: #0383FF;
}
A:link { text-decoration: none }
A:active { text-decoration: none }
A:visited { text-decoration: none }
</style>
</head>
<body>
<div id="updates">
<?php
/* Load required lib files. */
session_start();
require_once('twitteroauth.php');
require_once('config.php');
$twitterUser = $field_twitter_url;
$connection = new TwitterOAuth (CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET);
$statuses = $connection->get('statuses/home_timeline', array('screen_name' => $twitterUser));
foreach ($statuses as $status) {
?>
<div id="update">
<div id="left"><a href="https://twitter.com/#!/<?=$status->user->screen_name?>" target="_blank"/><img width="48px" height="48px" src="<?=$status->user->profile_image_url?>"/></a></div>
<div id="right">
<div class="user"><a href="https://twitter.com/#!/<?=$status->user->screen_name?>" target="_blank"/><?=$status->user->screen_name?></a> <?=$status->user->name?></div>
<div class="detail">
<?=$status->text?>
</div>
</div>
</div>
<?php
}
?>
</div>
</body>
</html>
I know the code is pretty rough at the moment.
The issues I am trying to solve are how to add a max return count of 5 to this existing code?
While this code currently works another issue I have noticed is that when a retweet by someone I am following is returned, instead of showing the profile_image of the original tweeter it show the profile_image of the retweeter. Also in the text of the retweet it starts by saying:-
RT @ and then the original tweeters screen_name.
By starting the text like this on retweets it causes the text in most cases to extended beyond the 140 character limit and thus part of the text is cut off.
I really want retweets to appear as they do on my Twitter home page i.e. the actual profile_image of the original tweeter along with their actual tweet and then a small piece of text above the message to say ‘RT by’ screen_name.
Any help appreciated…,
Kind regards.