Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook "like" - how to get the landing tab to redirect to another tab
    text
    copied!<p>I have a Facebook "landing tab" that is setup, and I have installed another tab that I would like to be activated after a fan clicks the "like" button. I have searched the Internet and come up with a mix of JavaScript and PHP SDK code but nothing has really worked for me so far.</p> <p>I guess there are two main problems:</p> <ol> <li><p>After the fan initially visits the site (they go directly to the landing tab) and clicks the "like" button, I would like the iframe to redirect to the other tab that I have created. I tried a simple JavaScript redirect (<code>windows.location = "URL"</code>) and that changed it to the URL I wanted but not within the Facebook iframe - obviously it was also not called by the clicking like action.</p></li> <li><p>If I can get the above working, the next problem is that once the like button is clicked I want the second tab to always be the default for the user.... Right now after the user hits "like" it directs to the wall page and again when the visitor returns to the page it is the wall page. If I get problem #1 working with the redirect will it then always default to that second tab or will it still be sending people to the wall when they revisit the page?</p></li> </ol> <p>Here is some code I found. Both JavaScript SDK and PHP SDK. Where am I going wrong?</p> <pre><code>FB.Event.subscribe('edge.create', function(response) { location.href = 'URLofSecondtab'; } ); </code></pre> <p>The above code is what I have been told is the Facebook event handler for <em>like</em> in JavaScript.</p> <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; window.fbAsyncInit = function() { FB.init({appId: 'idOfLandingTab', status: true, cookie: true, xfbml: true}); //FB.Canvas.setSize({ width: 520, height: 1500 }); FB.Event.subscribe('edge.create', function(response) { alert('like!'); // put redirect code here eg window.location = "URLofSecondtab"; } ); }; //Load the SDK asynchronously (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); &lt;/script&gt; </code></pre> <p>I have found the PHP SDK and have not been able to implement:</p> <pre><code>&lt;?php // Sample PHP code to customize the a Facebook Fan Page iFrame Application // Refer to http://www.hyperarts.com/blog/customizing-facebook-iframe-application- signed_request_reveal_tab require 'facebook.php'; $app_id = "APP_ID_HERE"; //which app id? the landing tab or the second tab that I want //redirected? $app_secret = "APP_SECRET_HERE"; $facebook = new Facebook(array( 'appId' =&gt; $app_id, 'secret' =&gt; $app_secret, 'cookie' =&gt; true )); $signed_request = $facebook-&gt;getSignedRequest(); $page_id = $signed_request["page"]["id"]; $page_admin = $signed_request["page"]["admin"]; $like_status = $signed_request["page"]["liked"]; $country = $signed_request["user"]["country"]; $locale = $signed_request["user"]["locale"]; echo "&lt;br&gt;page id = $page_id"; echo "&lt;br&gt;page admin = $page_admin"; echo "&lt;br&gt;like status = $like_status"; echo "&lt;br&gt;country = $country"; echo "&lt;br&gt;locale = $locale"; ?&gt; </code></pre> <p>Which tab URL and app id is required in what location? And what kind of code (the JavaScript or PHP code)?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload