有时我得到空数组作为API调用/我/ apperquests后发送请求通过request dialog 我使用来自Facebook的PHP SDK的PHP库,所以身份验证是可以的(例如/我打电话是好)。与Facebook apprequests问题
有人能帮助我,为什么会发生这种情况?万分感谢!
有时我得到空数组作为API调用/我/ apperquests后发送请求通过request dialog 我使用来自Facebook的PHP SDK的PHP库,所以身份验证是可以的(例如/我打电话是好)。与Facebook apprequests问题
有人能帮助我,为什么会发生这种情况?万分感谢!
调用/me/apprequests
搜索将返回从应用程序和朋友不是您发送别人的请求发送到您的要求!
apprequests - 用户未完成的应用程序请求。
我已经提出了一个解决方案来跟踪用户发送的请求,它的深度here描述。
简而言之,您将处理包含请求标识的apprequests
回调的响应,并将它们与用户(发件人)标识一起存储在数据库中。
代码:
<?php
// PATH TO THE FB-PHP-SDK
require_once '../src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'APP_SECRET'
));
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl();
if (empty($user)) {
echo("<script> top.location.href='" . $loginUrl . "'</script>");
exit();
}
?>
<!doctype html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<body>
<a href="#">Send Application Request</a>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true,
cookie : true,
xfbml : true,
oauth : true
});
};
$('a').click(sendRequest);
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'Check out this application!',
title: 'Send your friends an application request',
},
function (response) {
if (response && response.request_ids) {
var requests = response.request_ids.join(',');
$.post('handle_requests.php',{uid: <?php echo $user; ?>, request_ids: requests},function(resp) {
// do something
});
} else {
alert('canceled');
}
});
return false;
}
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
显然不是真正需要的PHP-SDK。
盲目猜测:FB REST API本身当前返回空响应或者Facebook PHP SDK中的cURL失败。 – toopay