Programming

response.session

Verifying Facebook’s Website Login javascript response.

0

Using the Facebook Login button for Website sign-in is nice and dandy with the current Facebook Javascript SDK. However scouring Facebook’s documentation failed to shed any light on how to do a verification check on FB’s response.

The Login button itself triggers 3 types of responses: “connected”, “notConnected” and “unknown”. More about their meaning can be found in Facebook’s documentation.

What I’m interested in is the response.session object, which looks like this:

To match the sig value, I need to do an md5 over all fields with values ordered alphabetically by field name and concatenate my Facebook APP Secret at the end.

So for instance by passing the response to PHP, I’d verify it with:

1
2
3
4
5
6
7
8
9
10
11
12
...
$compSig = md5(
                "access_token={$_POST['access_token']}".
                "expires={$_POST['expires']}".
                "secret={$_POST['secret']}".
                "session_key={$_POST['session_key']}".
                "uid={$_POST['uid']}".
                FB_APP_SECRET
                );
if($compSig != $_POST['sig']) {
    // Handle sig mismatch
}
Neko

PHP Benchmark: Calculate loop length in advance

0

As shown and tested on www.phpbench.com, calculating the size of your loop in advance can be a huge performance boost. Makes sense of course, still the nature of PHP could lead you to believe that there’s an optimization in place, even if there’s little sound logic supporting it.

1
2
3
4
// Faster
for ($i=0; $i < $size; $i++)
// Slower
for ($i=0; $i < sizeOf($x); $i++)
Count Benchmark

Count Benchmark

Antec P182

New Server & Dota Replay Parser

0

Arrrrrgh, the blog’s been stagnating for a while, but I blame the instability of my old server that discouraged me from posting anything. Coincidently however my ice breaking post relates to the scrapping of my old not-so-trustworthy server I’ve been keeping alive by feeding it spare parts. I’ve finally come to a point where I’ve setup a brand new machine with all new parts dedicated solely to acting as headless server and performing several other home network functionalities.

The rig I’ve put together consists of the parts listed bellow, all cased in a spanking new Antec P182, making the server the quietest piece of machinery I own.

Antec P182

Antec P182

Case and Cooling

  • Case: Antec P182 EU – 140 €
  • CPU Cooler: Scythe MUGEN 2 SCMG-2000 1366 – 45 €
  • Case Fan: Scythe Kama PWM 120mm – 10 €
  • PSU: Corsair VX 450W (CMPSU-450VXEU) – 71 €

Processing

  • Mobo: GA-EP43-DS3L – 68 €
  • GFX: NVIDIA GeForce 8400GS 256MB GDDR2 – 28 €
  • CPU: DC2 E5200, 2.500 GHz 2MB, 800Hz, LGA775 BOX – 63 €
  • RAM: Ram DDR2 Geil 2Gb PC6400 800 2Gb – 28 €

Storage

  • HD 1: WD 1 Tb SATA300 , 7200, WD10EADS, 32MB cache SATA-II/300 GREEN – 88 €
  • HD 2: WD 1 Tb SATA300 , 7200, WD10EADS, 32MB cache SATA-II/300 GREEN – 88 €
  • HD 3: WD 640 Gb SATA300 , 7200, WD6401AALS, 32MB cache SATA-II/300 – 64.5 €

CDP Dota Parser

Since the demise of CTS, the clan’s website’s been frozen so I’ve decided to move my pet Dota Replay parser project to this site.
It can be accessed as a page and I’ll be adding any future updates there.

Go to Top