Last Updated: February 25, 2016
·
631
· rkueny

Make a Like gate for Facebook

A litte code for detect user who have liked or not your page. Working on your facebook tab.

function parse_signed_request($signed_request)
{
    list($encoded_sig, $payload) = explode('.', $signed_request, 2);

    $sig = base64_url_decode($encoded_sig);
    return json_decode(base64_url_decode($payload), true);
}

function base64_url_decode($input) {
    return base64_decode(strtr($input, '-_', '+/'));
}

$datas = parse_signed_request($_REQUEST['signed_request']);

if($datas['page']['liked']) {
    // content for likers
} else {
    // like gate
}

2 Responses
Add your response

Interesting, would this be better to do in javascript?

over 1 year ago ·

@mdeiters Why do you want to do this in javascript ?

over 1 year ago ·