Archive for the 'idea' Category

Windows Mobile + Twitter / Facebook = UltraStalk Hack

Well, I have done it. I have managed to bridge that gap between my computer and my toilet… or my computer and my drive to work… or my computer and those boring lectures at school…. I no longer have to suffer through the pain of not having access to my live feed of everyones life. I can now continue my daily stalk even when I am not at my computer.

If you are like me, you have your Facebook status update feed for all of your friends in your favorite feed reader and set it to update every 1 minute. You also added your friend’s Twitter feeds. You may have even taken advantage of Facebooks SMS notification feature, where it txt-msgs you whenever a friend updates their status… Well, that was not good enough for me, and only provided me with limited info on a few people… I wanted INSTANT access to my Facebook/Twitter stalking resources!

So, I found a way. I own a Motorola Q, and I love it. Despite all of the problems everyone has with it and what everyone says, I find it to be the most useful mobile tool I have. I watch TV on it (SlingBox + Comcast Digital Cable), listen to music on it (SiriusWM5 for Sirius, and Orb for mp3s from my large library on my desktop PC), play SNES games on it (thank you PocketNesterPlus), use it for GPS navigation & phone book (Windows Live Search), instant message from it (Agile Messenger), and of course that phone/email/web thing as well. I WANTED MORE!

I wanted to move my obsessive Facebook/Twitter habits into my mobile lifestyle so I could stalk on the go. Here is my solution:

ss000.jpg

Notice the information that I circled in red. This the latest Facebook update from my entire set of friends. “Katie S. is on her way to target.” My homescreen is updated every 3 minutes with the latest status update from Facebook. Whenever someone updates their status, my phone makes a very light noise and the update is displayed on my home screen. ULTRASTALK! I see all and hear all now.

And now, here is how it works. I found a scripting language that works on mobile phones and has a nice set of functions and features. It is called MortScript. MortScript has the ability to read/write to the registry, download and read files from the internet, automatically run at specified intervals, etc etc etc… I created a very simple script that checks a PHP file on a server of mine, and saves the information to the phone. Then I added a built-in plugin to the home screen that displays that information. I currently only have it doing a live Facebook status update, but the PHP script could easily be made to pull Twitter, or even BOTH. This MortSCript is only for displaying the information, so really, the PHP script could grab ANY type of information, such as: server status, new email, feed updates (such as facebook/twitter), IM presence information, number of users on your website, new comments on your blog, important alerts (like a pager?). Really, I have created the framework for any type of instant mobile alerts.

MortScript:

scriptURL = "URL_TO_YOUR_SCRIPT"
ThisScriptPath = SystemPath("ScriptPath")
ThisScriptName = SystemPath("ScriptName") & SystemPath("ScriptExt")
 
#Update interval in seconds, 180 = 3 minutes.
UpdateInterval = 180
 
Call SetUpdateTime
 
#Turn Errors OFF
ErrorLevel("off")
 
Contents = ""
wURL = scriptURL
Contents = ReadFile(wURL)
OldContents = RegRead ("HKCU","ControlPanelOwner","Notes")
 
If (OldContents ne Contents)
	#For the Q
	RegWriteString ("HKCU","ControlPanelOwner","Notes", Contents)
 
	#Uncomment the following and change filename to play a sound
	#PlaySound("NewUpdate.wav")
EndIf
 
Exit
# -------------------------------------------------------------
Sub SetUpdateTime
If (UpdateInterval <> 0)
	RunAtTime = TimeStamp() + (UpdateInterval)
 
	#Remove the Notification Queue (if exists)
	RemoveNotifications(ThisScriptPath & "\" & ThisScriptName)
 
	#Set the Notification Queue Item
	RunAt(RunAtTime, ThisScriptPath & "\" & ThisScriptName)
EndIf
EndSub

PHP Script

$url = 'FACEBOOK_STATUS_FEED_URL';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
$xml = curl_exec($ch);
curl_close($ch);
 
$xmlobj = simplexml_load_string($xml);
$status = $xmlobj->channel->item[0]->title;
$author = $xmlobj->channel->item[0]->author;
$authorn = split(' ',$author);
 
switch(count($authorn)):
case 1: // single name
    $authorabbr = $authorn[0];
    break;
case 2: // first &amp; last name
    $authorabbr = $authorn[0].' '.$authorn[1]{0}.'.';
    break;
case 3: // first middle last, take first and last
case 4: // first middle last sr/jr/III, take first and last
    $authorabbr = $authorn[0].' '.$authorn[2]{0}.'.';
    break;
default:
    $authorabbr = 'Someone';
    break;
endswitch;
 
$status = str_replace($author, ucwords($authorabbr), $status);
 
echo $status;
?>

XML to add to your home screen file:

<plugin clsid="{4824B576-EFFE-45cf-BAE9-649B930CD244}" height="23">
	<background b-border-width="0"></background>
	<label halign="left" h="20" x="38" y="0" w="275" font-size="15" padding-right="0">
		<text><notes></notes>
       	</text></label>
</plugin>

You will obviously need to customize the XML to suite your current home screen needs (x,y,height,width,font-size, etc etc). Follow this link to download MortScript and install it. Name the script above ultrastalk.mscr and run it from filemanager to start it. If anyone is actually interested in using this, just leave a comment and I will post a follow up with step-by-step instructions.

Updating Facebook status using PHP

[UPDATE: October 01, 2007 @ 11:09am EST]
Facebook has officially implemented a users.setStatus() method in their API. Read more…

[UPDATE: September 04, 2007 @ 7:21pm EST]
It is with great disappointment that I must make this announcement. Facebook has requested that I remove the code from my website. They have also contacted everyone else who has found my code and publicly mentioned that they are using it. I originally did not comply, but my Facebook account was disabled and legal action was about to be pursued.

I am saddened at this turn of events because the idea behind the code was to extend Facebook’s current service and fill in the gap that their API had. The API still does not provide a means for updating ones status.

To everyone who found my code useful, everyone who ported my code to various other languages, those who integrated my code into their projects, and those who believe in Federated Status, Thank You.

- Christian Flickinger

I use Facebook as my ’social network of choice’, and the means for updating friends of my status. The main reason is because most of my friends have no idea what Twitter is, nor would many of them use it. Everyone I know does have a Facebook account though, so it seems only natural that I use the medium which will give my updates the largest audience.

Although I do not use Twitter, I fully support it and love the idea of it.

Out of curiosity, I wanted to see if I could meld Facebook and Twitter. What I envisioned was a one-stop shop for updating my statuses across the internet. To do this you would need something that can PUSH and ACCEPT updates. Twitter has an API that will ACCEPT updates, but nothing that will PUSH them. Facebook has an API that does not have any functions for status updates at all, but they do have status update RSS feeds. I want Twitter to be the top of my update tree. I want to update twitter (because of its SMS/Web/IM/API updating capabilities) and have everything else know about it. The API allows me to make a plugin for my IM client that could possibly throw my latest away message up on Twitter. SMS/Web/IM allow me to update twitter from wherever I am.

The problem with Facebook: You can only PULL status updates, and until now, you can not UPDATE them programaticaly. Searching google I quickly find a way to manually post my Facebook status to Twitter and a post that lays out the possibilities for facebook-twitter integration.

Well, I do not give up that easy. I want a way to update Facebook without physically logging into Facebook. It can be done, and I found out how. Facebook has no status update API and their update box uses AJAX to post, so cURL is out of question… or so everyone thought! Facebook has a mobile service (http://m.facebook.com) that allows you to update your status and view your Facebook from a cellphone. It looks the best on Windows Mobile devices (I have a Q), and works great on normal WAP browsers. This is the key to my facebook-twitter hack.

Facebook mobile uses a normal POST method for updating status. How cool is that? This means that it HAS to be possible to update your Facebook from a program. Using nothing but cURL (or, in my case, PHP with the cURL extension), you can update your Facebook status. What does this mean? This means that if someone wanted, they could easily keep their Facebook status synced up with their latest Twitter status. The code is below. Feel free to use it. Mentioning my blog/name would be greatly appreciated.

// Code removed at request of Facebook

I have already created my first test mashup of Winamp & Facebook, successfully displaying, in real time, the current song I was listening to in Winamp as my Facebook status. Anyone with some experience could easily use the above code to check Twitter and (if updated) push to Facebook. Happy mashing!