Thanks... I should've posted the whole thing because now I'm getting
another error! This is what I'm trying to do (I really appreciate your
help!):
<?php
/* Load required lib files. */
require_once('twitteroauth/twitteroauth.php'); /* This is the
library for connecting with oAuth */
require_once('config.php'); /* This is the file that contains
the oAuth credentials - this will be different for each app */
//$twitterUser = 'YOUR_FRIENDS_USERNAME';
$twitterUser = $field_twitter_url;
/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET);
$statuses = $connection->get('statuses/user_timeline',
array('screen_name' => $twitterUser'));
//create a time display like '1 hour ago'
function twitterTime($time) {
$delta = time() - $time;
if ($delta < 60) {
return 'less than a minute ago.';
} else if ($delta < 120) {
return 'about a minute ago.';
} else if ($delta < (45 * 60)) {
return floor($delta / 60) . ' minutes ago.';
} else if ($delta < (90 * 60)) {
return 'about an hour ago.';
} else if ($delta < (24 * 60 * 60)) {
return 'about ' . floor($delta / 3600) . ' hours ago.';
} else if ($delta < (48 * 60 * 60)) {
return '1 day ago.';
} else {
return floor($delta / 86400) . ' days ago.';
}
}
//this is an empty string container we're going to pass the
result of our loop into
$twitterString = "";
foreach ($xml->status as $entry)
{
// there are more elements to choose from see:
http://apiwiki.twitter.com/REST+API+Documentation#Statuselement
$status = $entry->text;
$profilePic = $entry->user->profile_image_url;
$profileName = $entry->user->screen_name;
$statusRealName = $entry->user->name;
$profileURL = $entry->user->url;
$statusDate = $entry->created_at;
$statusSource = $entry->source;
$statusDateFormatted = twitterTime(strtotime($statusDate));
$profileBio = $entry->user->description;
$statusFollowCount = $entry->user->followers_count;
echo "<div class=\"post hentry\">\n";
echo "<div class=\"image-box\">\n";
echo "<img class=\"photo\">\n";
echo "<a href=\"http://www.twitter.com/$profileName\" target=
\"_blank\"><img class=\"userPicThumb\" src=\"$profilePic\" alt=
\"$profileRealName\" /></a>\n";
echo "</div>\n";
echo "<div class=\"text-box\">\n";
echo "<div class=\"meta\">\n";
echo "<strong class=\"post-link\">\n";
echo "<a class=\"entry-title\" href=\"http://www.twitter.com/
$profileName\" target=\"_blank\">$profileName</a>\n";
echo "</strong>\n";
echo "<span class=\"vcard\"><span class=\"fn\">
$statusRealName</
span></span>\n";
echo "</div>\n";
echo "<p class=\"entry-content\">$status</p>\n";
echo "<div class=\"time\">\n";
echo "<span>$statusDateFormatted from $statusSource</span>\n";
echo "</div>\n";
echo "</div>\n";
echo "<div class=\"clear\"></div>\n";
echo "</span>\n";
echo "</div>\n";
}
?>
On Mar 25, 3:52 pm, Abraham Williams <[email protected]> wrote:
> Oops. I had a type. The = needs a > directly after it like =>
>
> Abraham
> -------------
> Abraham Williams | Hacker Advocate | abrah.am
> <http://abrah.am>Just launched from Answerly <http://answerly.com>:
> InboxQ<http://inboxq.com>for Chrome
> @abraham <https://twitter.com/abraham> | github.com/abraham | blog.abrah.am
> This email is: [ ] shareable [x] ask first [ ] private.
>
>
>
>
>
>
>
> On Fri, Mar 25, 2011 at 15:44, Jon <[email protected]> wrote:
> > Thanks Abraham,
>
> > I'm getting an error on the last line there though:
>
> > "Parse error: syntax error, unexpected '=', expecting ')' in ..."
>
> > On Mar 25, 3:33 pm, Abraham Williams <[email protected]> wrote:
> > > You are not formatting the GET request correctly and TwitterOAuth
> > > automatically parses the JSON response for you.
>
> > > <?php
> > > /* Load required lib files. */
> > > require_once('twitteroauth/twitteroauth.php'); /* This is the
> > > library for connecting with oAuth */
> > > require_once('config.php'); /* This is the file that contains
> > > the oAuth credentials - this will be different for each app */
>
> > > //$twitterUser = 'YOUR_FRIENDS_USERNAME';
> > > $twitterUser = $field_twitter_url;
>
> > > /* Create a TwitterOauth object with consumer/user tokens. */
> > > $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
> > > OAUTH_TOKEN, OAUTH_TOKEN_SECRET);
>
> > > $statuses = $connection->get('statuses/user_timeline',
> > > array('screen_name' = $twitterUser'));
>
> > > Abraham
> > > -------------
> > > Abraham Williams | Hacker Advocate | abrah.am
> > > <http://abrah.am>Just launched from Answerly <http://answerly.com>:
> > > InboxQ<http://inboxq.com>for Chrome
> > > @abraham <https://twitter.com/abraham> | github.com/abraham |
> > blog.abrah.am
> > > This email is: [ ] shareable [x] ask first [ ] private.
>
> > > On Fri, Mar 25, 2011 at 14:50, Jon <[email protected]> wrote:
> > > > Hello,
>
> > > > I am having trouble with the below code... I am trying to pull a
> > > > user's timeline. Can someone please let me know where I've gone wrong?
>
> > > > <?php
> > > > /* Load required lib files. */
> > > > require_once('twitteroauth/twitteroauth.php'); /* This is the
> > > > library for connecting with oAuth */
> > > > require_once('config.php'); /* This is the file that contains
> > > > the oAuth credentials - this will be different for each app */
>
> > > > //$twitterUser = 'YOUR_FRIENDS_USERNAME';
> > > > $twitterUser = $field_twitter_url;
>
> > > > /* Create a TwitterOauth object with consumer/user tokens. */
> > > > $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
> > > > OAUTH_TOKEN, OAUTH_TOKEN_SECRET);
>
> > > > $xml = $connection->get('statuses/user_timeline.xml?screen_name=
> > > > $twitterUser');
> > > > $xml = new SimpleXMLElement($xml);
>
> > > > Thanks,
>
> > > > Jon
>
> > > > --
> > > > Twitter developer documentation and resources:
> >http://dev.twitter.com/doc
> > > > API updates via Twitter:http://twitter.com/twitterapi
> > > > Issues/Enhancements Tracker:
> > > >http://code.google.com/p/twitter-api/issues/list
> > > > Change your membership to this group:
> > > >http://groups.google.com/group/twitter-development-talk
>
> > --
> > Twitter developer documentation and resources:http://dev.twitter.com/doc
> > API updates via Twitter:http://twitter.com/twitterapi
> > Issues/Enhancements Tracker:
> >http://code.google.com/p/twitter-api/issues/list
> > Change your membership to this group:
> >http://groups.google.com/group/twitter-development-talk
--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group:
http://groups.google.com/group/twitter-development-talk