This forum is in permanent archive mode. Our new active community can be found here.

Twitter Code

edited August 2008 in Technology
Could anyone link me to a piece of code or create one, with which I can just display my current twitter status with one line of text in an html?

Edit:

I've come as far as to show my latest post in the Twitter RSS feed with: http://twitter.com/statuses/user_timeline/USERNAME.rss?count=1
So I just have to find a way to display the latest/ only post as plain text.

Edit II:

Why does this script not work?<?php
function twitter_status($hyperlinks = true) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/15085077.xml");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$src = curl_exec($c);
curl_close($c);
preg_match('/<text>(.*)<\/text>/', $src, $m);
$status = htmlentities($m[1]);
if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $status);
return($status);
}

Comments

  • If your web page is written in PHP, there's this:
    http://lab.arc90.com/2008/06/php_twitter_api_client.php

    Will that do what you're looking for?
  • That code is not displaying correctly *at all*. Can you throw it on pastebin or somesuch?
  • Will that do what you're looking for?
    I just want my current Twitter status to be displayed in a line of text. ^^
    And I know - I have barley knowledge of PHP.
  • edited August 2008
    I solved my problem now:

    I first patched together a bit of code: Download

    Then I added the "Twitter Bird" and the script into my site:

    image

    Most credit goes to SleepyDisco.
    Post edited by kiwi_bird on
  • I first patched together a bit of code: Download
    Realize that your server processes that php file too before sending it to the client. n.~
  • I know. I hoped anyone who would try it would just right click and "Save As..".
  • I know. I hoped anyone who would try it would just right click and "Save As..".
    Look up, there's a point flying. I right-clicked > Save as... the first time, but I hope you realize that makes no difference compared to just opening the file in a tab, right? It's still a GET request, your server still processes the php file before sending it.

    In other words that go directly to the point, exclude it from your preprocessor, or append .txt to the filename.
  • I just realized my flaw.. Your right. ^^" I edited the link. Should work now.
  • Anyone used this before?
  • I have, but it just does too much. ^^
Sign In or Register to comment.