我正在尝试在页面标签应用程序中实现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"]);
}
答案 0 :(得分:0)
您正在寻找request dialog:
<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>
所以你的&#34;链接&#34;不应该调用真正的URL,而是使用Javascript函数打开请求对话框(在上面的示例中它将是sendRequestViaMultiFriendSelector()
)。