您可以只检查 Facebook响应对象中的内容,因为无论是否发送了请求,它都不一样!
就像是 :
function requestCallback(response)
{
if(response && response.request_ids) {
// Here, requests have been sent, facebook gives you the ids of all requests
//console.log(response);
location.href='step2.php';
} else {
// No requests sent, you can do what you want (like...nothing, and stay on the page).
}
}
或者,如果您使用的是新结构(Request 2.0 Efficient):
function requestCallback(response)
{
if(response && response.request) {
// Here, requests have been sent, facebook gives you the request and the array of recipients
//console.log(response);
location.href='step2.php';
} else {
// No requests sent, you can do what you want (like...nothing, and stay on the page).
}
}
查看响应对象的结构以制定您的条件。即使您点击关闭,也会触发回调,以便有可能注意到您的用户何时退出对话框。由您来验证他是否发送了请求,并按照您的意愿行事!:)
此外,还有一些重要的事情:Facebook 几周前更新了他们的请求系统,在您的应用设置中提供了“请求 2.0”。默认情况下它是关闭的,但是如果你激活它,向人们发送请求时响应对象的结构将会改变。所以你必须在回调中更新你的条件!
一切都在这里解释:http:
//developers.facebook.com/blog/post/569/