For the past 4 or so months I’ve been really enjoying my new Roland Juno G keyboard, it’s an amazing machine! I put together a how-to style video tutorial which explains how to create a hip hop loop using the Juno G’s midi feature.
A few months ago I broke down and joined Twitter. Pretty much the only reason is that I wanted to learn how to integrate Twitter into PHP web applications. Here’s what I found:
Twitter has a URL http://www.twitter.com/statuses/update.xml where you can POST a twitter update. The following HTML form will update your twitter status after asking you for your username and password:
This is cool, but it would be nice to circumvent the password protection in a web application where you probably already have a user logged in and validated? Fortunately this is possible using HTTP headers: (please make sure you read my SECURITY NOTE below)
Please notice that the code above sends the username and password hash unencrypted over a plaintext HTTP pipe. The password hash is thus vulnerable to rainbow table attacks.
A better solution uses HTTPS with cURL. This way, the username & password hash info don’t have to be sent plaintext:
Since I’ve started using twitter I’ve found that it’s very useful for companies and organizations that want to get messages out to lots of people quickly. You can even get twitter updates by phone using SMS!
Finally, almost done with school. Start the countdown, I’m graduating from UW-Madison! My last exam is on May 12, so I count that I graduate at noon that day.
A few posts ago I wrote about using a PHP class to convert an ICO image to a PNG (or GIF or JPG). I just discovered a bug in the class.
I ran into a problem where some red and orange ICO images turned blue during the conversion. Reading this forum post made me realize that the red and blue values were switched somewhere in class.ico.php. With some experimentation I found it:
In class.ico.php, lines 264-267 need to be changed from
As mentioned in my previous post, I’ve been finishing up a facebook application, My Sites. Now that it’s done, I thought I’d post a few tips on how to add profile boxes to your facebook application, since I found it maddeningly complicated.
For the non-facebook-savy, a profile box is a small box that applications can add to your profile’s “wall” or “boxes” tabs. They’re meant to provide a quick glimpse of what’s happening with the application.
I’m assuming that you keep a database of Facebook users, and you want to display something about them in the profile box.
The basic code for adding a profile box is below, annotated with copious comments. This is in PHP code, you can do it in other languages, but it’s what I use. Pop this code into a daily cron for example, and you’re good to go.
<?php
// This code connects to the facebook API.
@require_once 'facebook-platform/php/facebook.php';
$appapikey = 'facebook app api key';
$appsecret = 'facebook app api secret';
$facebook = new Facebook($appapikey, $appsecret);
// This code connects to your own database.
$BASEURL = "http://example.com/path/to/facebook/app";
$connection = @mysql_connect("server","username","password");
if(!$connection)die("Can't connect to the database at this time.");
$res = @mysql_select_db("database");
if(!$res)die("Site database doesn't seem to exist.");
// This code cycles through each user in the database
$sql="SELECT * FROM users";
$data=@mysql_query($sql);
while($user=mysql_fetch_assoc($data)) {
// You can, of course, query your database to build these strings
$WideBox = "Whatever you want a profile box on the 'boxes' tab to say.";
$MobileBox = "Whatever you want a profile box accessed by a mobile device to say.";
$NarrowBox = "Whatever you want a profile box on the 'wall' tab to say.";
// This is the API call, it sets the user's profile box content:
$facebook->api_client->profile_setFBML(
NULL, // This is the markup, set to NULL for 'FBML'
$user['id'], // ID number of the user whose profile box you want to set
$WideBox, // Wide box content for 'boxes' tab
NULL, // Deprecated, should always be NULL
$MobileBox, // Box content for mobile devices
$NarrowBox // Narrow box content for 'wall' tab
);
}
// Clean up the connection
@mysql_close($connection);
?>
So I’ve been developing a FaceBook application, My Sites. It let’s you bookmark websites you like and share them with your friends.
The Problem
When a FaceBook application tries to add HTML to someone’s profile box, it can add images, but only in JPG, GIF, or PNG formats. For most uses this is fine, but I needed to add a favicon next to each website in a list, and ICO format isn’t allowed.
The Solution
Using a free php class that can import ICO images to a GD image resource, I converted the favicons to PNGs. Now FaceBook is all happy. Download a ZIP of the icon class here, or directly from PHPclasses.org.
This is my new blog. I’ll be posting here periodically, mostly on random tech topics. Gadgets and articles I find interesting, solutions to web development problems I encounter, reviews, how-tos, and the like. Occasionally I may post something totally unrelated but I’ll try not to .
Thanks for visiting. Please stop by often to check out my blog, or keep up via RSS!
Welcome!
Hi! I'm Tom Reitz, a Catholic web developer from Madison, Wisconsin. I blog about technology and Catholic news and events.
I am liberal (I believe in the importance of liberty and equality), but socially conservative.
I believe that everyone must take responsibility for their own actions.
I think that saving is better that spending.
I understand that exercising self-control is easier than letting someone else control you.