PHP/Curl script date help

8 views
Skip to first unread message

Dean

unread,
Apr 6, 2011, 6:52:21 AM4/6/11
to Twitter Development Talk
I have a script to put my Twitter feed on my site but can't work out
how to get it to show the date/how long ago it was posted.

Can anyone tell me what I need to add?

<?php
// create curl resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "http://api.twitter.com/1/
statuses/user_timeline.xml?screen_name=USERNAMEHERE&count=1");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);
$tweetData = simplexml_load_string($output);
// close curl resource to free up system resources
curl_close($ch);
?>




<?php

if(count($tweetData)){
echo "<p>";
foreach($tweetData as $tweet){


echo "$tweet->text";

}


echo "</p><p>A</p><a href='http://twitter.com/
USERNAMEHERE' target='_blank'>Follow us</a>";
echo "</p>";
}
?>

Scott Wilcox

unread,
Apr 6, 2011, 10:14:59 AM4/6/11
to twitter-deve...@googlegroups.com
> foreach($tweetData as $tweet){
>
>
> echo "$tweet->text";
>
> }


echo $tweet->created_at;

> --
> 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

--
Scott Wilcox

@dordotky | sc...@dor.ky | http://dor.ky
+44 (0) 7538 842418 | +1 (646) 827-0580

Reply all
Reply to author
Forward
0 new messages