开发者

Dynamic iframe source on facebook pages

I am trying to make it easy for users of our site to deploy widgets hosted on our server on their facebook pages, as an iframe.

We don't want to use <fb:iframe /> coz apparently they are not allowed and wont be supported in the future.

Following the instructions here, this is what we did :

  1. We created an application with

    1. Canvas Settings:

      • canvas page url : http://apps.facebook.com/{app-name}/
      • canvas url : http://{my-server}/fb/
      • render method: FBML
    2. Profile Settings:

      开发者_运维知识库
      • Tab Name : {tab_name}
      • Tab Url: http://apps.facebook.com/{app-name}/{app-name}?wid={unique_identifier}
  2. Created a facebook page and added the application to the page.

  3. and index.php under "fb" folder in our web server docroot is as follows:

    <?php
        echo '<a onClick="outside_location.setInnerFBML(link_1);console.log(link_1)" style="cursor: pointer;">Let\'s see the iframe here</a>';
        echo '<div id="outside_location"></div>';
        echo '<fb:js-string var="link_1">';
        $wid = $_GET['wid'];
        echo "<iframe height='500' allowTransparency='true' frameborder='0' scrolling='no' style='width:100%; border:none' src='http://<some_domain>/$wid' >";
        echo '</iframe>';
        echo '</fb:js-string>';
        echo '<script type="text/javascript" charset="utf-8">
        var outside_location = document.getElementById("outside_location");
        </script>';
    ?>
    

The above steps work. But we want to make it easier to do this. Right now, our users have to go through this tedious process of creating a facebook application and add it to the facebook page, just for putting their widget on their facebook pages. Is there a way to use some facebook api to automate this or reduce the number of steps involved ?

Every widget we provide to the user, has a unique id and url. So, when a user creates a new widget on our site, we want to be able to tell the user some quick and easy steps to be able to add the widget to their facebook page OR completely automate the whole process if possible.


If this is a tab application then you can use the page_id. Facebook should be passing it to you. This looks to be an older style FBML style app. You might find it's easier to convert your app to iFrame and use the signed_request POST variable that is passed to identify the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜