简体   繁体   中英

Like Gate on new timeline Brand pages

I have always had a like gate for brand pages for both a welcome page and for product pages, Q&A pages etc. The code I was using was as follows

<? require 'facebook.php';
$app_id = "[MY-APP-ID-HERE]";
$app_secret = "[MY-APP-SECRET-HERE]";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));

$signed_request = $facebook->getSignedRequest();

$like_status = $signed_request["page"]["liked"];

if ($like_status) {

//You have liked the page

} else {
//You need to like the page
}

?>

Now with the new time line this like layer isn't working the way it used to. If you didn't like the page it came up with the like section then when you clicked like up the top it redirected to the like section of the if/else statement but now with time line it doesn't.

If you could help with a way to do this with the new time line layout for pages that would be so helpful.

Here's a solution that I threw together yesterday. It consists of Like Button plugins and the Javascript SDK.

Facebook JS API reference

First, you'll need to create a Like Button plugin (http://developers.facebook.com/docs/reference/plugins/like/) which you'll add to your tab. You'll no longer want users to click your Page's Like Button...only the Like Button Plugin (huge difference)

Secondly, using the Javascript SDK, you'll want to "listen" for clicks on the Like Button Plugin. This is achieved using the SDK API FB.Event.subscribe call listening for 'edge.create'.

Facebook JS API reference event subscribe

Example code:

    FB.Event.subscribe('edge.create',
        function(response) {
        document.location = 'fanrevealed.php';
        });
    };

The above example redirects a user to the reveal tab.

Please feel free to hit me up on Twitter if you need help.

@jeremyhilton

You can subscribe to the assigned Facebook Bug :) Facebook Bug 228778937218386

As an option/workaround, you could use the Hike Tab Builder with Fan Gating Plus+ to include the Like Button which uses FB.Event.subscribe('edge.create') to fade out the non fan content after like click: Facebook Hike Social App Page

UPDATE: Bug is fixed by Facebook!

The "old" Like button caused the page to refresh, meaning the server-side check would do it's job. The new Like button doesn't cause a refresh, I haven't seen any mention of a JS callback, not that I know how it would since it's running in another JS sandbox.

The like gate still works. The only problem is the page doesn't refresh to get your fan only content. If you click the like and then manually refresh it should still work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM