0

我正在尝试在页面选项卡应用程序中实现 facebook 请求。我在这里看到了教程http://developers.facebook.com/docs/appsonfacebook/tutorial/但问题是我希望下面的代码仅在有人访问类似的链接时执行

<a href = "something">Send to friends</a>

关于如何做到这一点的任何想法?谢谢!

   $requests_url = "http://www.facebook.com/dialog/apprequests?app_id=" 
            . $app_id . "&redirect_uri=" . urlencode($the_url_of_the_tab_page)
            . "&message=" . $message;

     if (empty($_REQUEST["request_ids"])) {
        echo("<script> top.location.href='" . $requests_url . "'</script>");
     } else {
        echo "Request Ids: ";
        print_r($_REQUEST["request_ids"]);
     }
4

1 回答 1

0

请求对话框是您要查找的内容 :

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
    <title>Request Tester C</title>
  </head>

  <body>
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <p>
      <input type="button"
        onclick="sendRequestToRecipients(); return false;"
        value="Send Request to Users Directly"
      />
      <input type="text" value="User ID" name="user_ids" />
      </p>
    <p>
    <input type="button"
      onclick="sendRequestViaMultiFriendSelector(); return false;"
      value="Send Request to Many Users with MFS"
    />
    </p>

    <script>
      FB.init({
        appId  : 'YOUR_APP_ID',
        status : true,
        cookie : true,
        oauth: true
      });

      function sendRequestToRecipients() {
        var user_ids = document.getElementsByName("user_ids")[0].value;
        FB.ui({method: 'apprequests',
          message: 'My Great Request',
          to: user_ids, 
        }, requestCallback);
      }

      function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'My Great Request'
        }, requestCallback);
      }

      function requestCallback(response) {
        // Handle callback here
      }
    </script>
  </body>
</html>

因此,您的“链接”不应该调用真正的 url,而是调用 Javascript 函数来打开请求对话框(在上面的示例中它将是sendRequestViaMultiFriendSelector())。

于 2012-01-20T20:47:40.403 回答