>
>
> echo "$tweet->text";
>
> }
echo $tweet->created_at;
On 6 Apr 2011, at 11:52, Dean wrote:
> 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>";
> }
> ?>
>
> --
> 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 | scott@dor.ky | http://dor.ky
+44 (0) 7538 842418 | +1 (646) 827-0580
--
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
No comments:
Post a Comment