blog

Privatizing the Twitter API Feed

Tagged:  

UPDATE: Check the comments for a version with caching.

A friend of mine recently had a rather unfortunate event involving her twitter public timeline, so I thought the time had come to make mine private, more or less.

As a result, I needed to update the code that pulls my most recent Twitter posts into the left hand column so that it would authenticate using the Twitter API. Here's the new code - it ain't pretty, but it works:

<?php
 
// Your twitter username & password.
$username = "YOUR_USERNAME";
$password = "YOUR_TWITTER_PASSWORD";
 
//Concatenate the username and password
$userpass = $username . ":" . $password;
 
//Make up the feed URL
$feed = "http://twitter.com/statuses/user_timeline.atom?count=1";
 
//A function to parse the atom feed and pull out the useful info.
function parse_feed($feed, $username) {
  $stepOne = explode("<content type=\"html\">", $feed);
  $stepTwo = explode("</content>", $stepOne[1]);
 
  $tweet = $stepTwo[0];
  $tweet = str_replace("&lt;", "<", $tweet);
  $tweet = str_replace("&gt;", ">", $tweet);
  $tweet = str_replace($username . ":", "", $tweet); 
  return $tweet;
}
 
//Create a curl object, give it the feed and authentication
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL, $feed);
curl_setopt($curl_handle,CURLOPT_USERPWD, $userpass);
 
//Return the result, don't print it.
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER, 1); 
 
//Make the connection, set the variable, close the connection.
$twitterFeed = curl_exec($curl_handle);
curl_close($curl_handle);
 
//Echo the parsed feed. Done.
echo parse_feed($twitterFeed, $username);
 
?>

One dependency is the php-curl library, and after you install that, apache2 will want a restart.

Twitter (and Facebook) Integrated

Tagged:  

I upgraded the site a bit today by adding my Twitter/Facebook feed to left-hand sidebar. To a teenager in Colorado I am indebted for this script. Jeez, they just get younger and younger.

Let me know if you catch any bugginess.

Marvelous RSS, Marvelous Google

Tagged:  

I've been working on the site a fair amount lately, and have added a couple of new features. The first one is a set of those ubiquitous bookmarking buttons for Technorati, del.icio.us, etc. that you should be seeing if you are reading this online. I've been trying to optimize this blog for a bit, and I figured I probably need these sooner or later.

The other thing I added today is the "Subscribe" block, which for the moment is listed on the left under the recent music. I did a little playing around in the heart of Drupal, and modified this block so that it has text links for RSS and for an email service I just discovered from Google.

Taxonomy Features Are Go

Tagged:  

I have been rather busy since starting this blog many months ago, so I never got to finish rounding out its features. One that I have been wanting to figure out and to apply was Drupal's taxonomy feature, which allows you to categorize your content as you write it.

After I turned it on today, I had to make up about 40 terms categorizing the content that I have written thus far, and I am now in the process of quickly going through and applying these tags to my old entries. What's cool about having this feature turned on is that in the future, say, when I have 80 gazillion entries about various topics, if you are a reader of the blog, you can easily find entries matching your interests. Assuming, of course, that I write 80 gazillion things.

Old Versions of Site are Up...sort of...

Tagged:  

I was working on getting the old versions of the site up and going for history's sake, and I have more or less accomplished the task, though I learned a very important lesson in the process.

For one, I learned that if you want to host additional custom directories on your drupal site, it's a piece of cake: Just make the directories in your drupal directory, and you're done. For example, my drupal directory is at /usr/share/drupal-5.1, so to host a page at michaeljaylissner.com/oldsite, I just made a directory at
/usr/share/drupal-5.1/oldsite, put stuff in it, and was done.

The more important lesson was that when hand-coding HTML, as I did in the previous version of the site, relative links such as /assets/picture1.jpg are NOT the same as relative links such as assets/picture1.jpg. Both work, but only one is actually relative to the current page (the latter one). The former one may as well have been written michaeljaylissner.com/assets/picture1.jpg, because that's what that first slash means. Duh.

Somehow, I never ran into this problem before now. Anyway, if you take the time to check out the old site (which I don't really recommend), you'll find many broken links. This is why.
The other project I have been working on is getting all of my pictures from the old site set up on this site in a place where registered users can find them. This is a work in progress, but if you're a registered user, you might be interested to see them, if you haven't already.

This is it. Drupal systems are go.

Tagged:  

Well, I can't say I have had a serious blog before, so with this very sentence, I am forging new ground for myself, and through the strange magic of the Internet, for everybody else in the world (except China, who I will now block from this blog by writing the following word: "democracy").

There's a pressure here of course not to have any typos and to make this post significant and poignant, but if I know me - and I think I do - I shouldn't set high bars like that for myself. I should just enjoy the medium, allow mistakes early and often, and proceed with the reason I am here to write today, which, according to the title of this post is to discuss the software of this very blog.

It's an interesting thing setting up a blog in your house. For some reason, it's really bloody complicated. First, you've got to learn how your house is networked, then how the Internet is networked. Once you think you've got that figured out, you have to get a faster Internet connection (cable as opposed to DSL), and if you are feeling spry, perhaps a static IP. I'm not feeling spry, and so, dyndns.com is my friend.

The next step once the networking is figured out is to figure out the software and hardware sides of things. This is not an easy task either. In the end, I have set up two computers to run this here blog. One to run Drupal, Apache, etc., and the other to do the mail serving. For the CMS, I have chosen Drupal because it seems to be all the rage, and because it has a stupid song that got caught in my head for far too long (see youtube for details). Drupal is of course running on GNU+Linux, Apache, PHP, and MySQL. As for the mail server, it would be running Zimbra, but at the moment it is crashed. I can't make it stop overheating, and it's rather annoying.

Anyway, once that's up and going, everything should be a go, and I will be a proud Internet host. Only one question truly remains: Is my IP on an anti-spam blacklist? We shall soon find out.

Syndicate content