Search

Rss Posts

Rss Comments

Login

 

Posts from September 1st, 2009

Mo’ Mashup

Sep 01

OK, so now the Facebook API is integrated, and seems to be working as expected. You plug in a city/state or ZIP, and the app finds folks you know in a 150 mile radius. It’s a little slow because I am loading all friends right now. It also only knows what people have put in their ‘current location,’ so you won’t see anyone who hasn’t provided that info. Still pretty good.

Also cleaned up some links with some logic (i.e. no longer gives a link to the next page of job search when there are no results!).

Found a nice function I adapted for PHP to compare two geocodes:

function ToRadian( $val) { return $val * ( pi() / 180); }
function DiffRadian( $val1,  $val2) { return ToRadian($val2) - ToRadian($val1); }
function  CalcDistance( $lat1,  $lng1,  $lat2,  $lng2, $m='') {
$radius = ($m == 'km')? 6367.0:3956.0;
return $radius * 2 * asin( min(1, sqrt( ( pow(sin((DiffRadian($lat1, $lat2)) / 2.0), 2.0) + cos(ToRadian($lat1)) * cos(ToRadian($lat2)) * pow(sin((DiffRadian($lng1, $lng2)) / 2.0), 2.0) ) ) ) );
}

Which I found at this nice person’s blog (thanks to Chris Pietschmann!)

I am using it to compare the friend’s location with the city/state/zip of the job search. So far, so good!