Wednesday, July 16, 2008

More Facebook Programming - Application Login Issues

Alright Facebook programmers....
I developed my first facebook app, only to be stumbled by an annoying Facebook issue. First off, FB requires users to be logged into applications in order to use them. I am ok with this. It helps log statistics, etc...metrics developers shoud have access to.

My problem...

When a user would view my application (I didn't want them to be required to add it), they would login and be redirected INCORRECTLY.

I.e.
http://apps.facebook.com/appName/main.phphttp://my.appsite.com/appName/?auth_token=XXXXX

Note the "...main.phphttp://..."

Ultimately, this is due to the "next" variable in the query string on the login page, but unfortunately, it is difficult to change. There have been a few comments on this at: http://forum.developers.facebook.com/viewtopic.php?id=16199
as well as some other threads...seems to be quite an issue.

HOWEVER:
I have an alternative way around this that I find to be much easier to control!

PHP Code as follows (using the FB PHP5 library):

require_once 'facebook.php';

$appapikey = '3b2XXXXXXXX14';
$appsecret = 'aa2XXXXXXXX06';

$facebook = new Facebook($appapikey, $appsecret,
$_GET['fb_sig_session_key'].$_POST['fb_sig_session_key']);

$user = $facebook->get_loggedin_user();

if($user=="") {
//Force a login to the app with the CORRECT "next" url
$urlRedirect="http://www.facebook.com/tos.php?api_key=XXXXXXXXXX
&next=page.php&v=1.0&canvas";

$facebook->redirect($urlRedirect);
}



If the user is NOT logged into the application, the user will be asked to login and redirected to whichever page follows the "next" variable in the query string. In the above example, the user would be redirected to: http://apps.facebook.com/appName/page.php

There you have it! Enjoy, and comments are welcome!

Monday, May 12, 2008

Who is viewing my Facebook page? I'll tell you!

Many people have asked me, "how can I tell which of my friends are viewing my profile?"
I know some people may say that entering some very simple logging code onto your Facebook account would be a violation of the owners privacy. However, I beg to differ. In fact, social network sites are prone to stalkers in the worst way. Granted, Facebook does an excellent job in protecting the privacy of people (well maybe not by default, but you have the option to turn all the "alerts" off).

Ultimately this code came out of a quest for logging MySpace traffic, which in my opinion, does very little to protect it's users. Yes, you can set your profile to "private," but I think that is the extent of it.

So which of my friends is viewing my Facebook profile? Let me tell you how to find out.

---------------------------------------------------------------------------------

As it turns out, Facebook does an EXCELLENT job of NOT giving you any information regarding who views you. However, I have found a pseudo-work-around.

There is a canvas application called "SuperProfile" (http://apps.facebook.com/logpages/) which displays much of your Facebook profile information (should you allow it to). Personally, I think it does a much better job than the Facebook published profile by separating the information in tabs. It also uses some Apple-ish looking animations and better photo viewing (just my opinion, after all this is a blog).

The app has a function (via "Setup" after you have installed the app) for profile monitoring which seems to be run by Logpages.net. They do charge $1 per month, but you get to see who views your SuperProfile pages, where they are located, and some other information.

So, all in all, not a perfect solution. But when you realize that people who view your SuperProfile must have entered the app via your Facebook Profile...the rest is history.