-7
我需要從網站發送fb邀請並計算髮送邀請的數量。如果發送的邀請數量是5,則只有內容會顯示,否則會顯示錯誤消息。我是新的API,所以請建議我使用PHP什麼和如何做。朋友邀請並計算髮送的邀請
等待最早的迴應。
感謝
我需要從網站發送fb邀請並計算髮送邀請的數量。如果發送的邀請數量是5,則只有內容會顯示,否則會顯示錯誤消息。我是新的API,所以請建議我使用PHP什麼和如何做。朋友邀請並計算髮送的邀請
等待最早的迴應。
感謝
We can test from localhost?
<?php
// PATH TO THE FB-PHP-SDK
require_once 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => '220998421586280',
'secret' => 'fb99179c8d2d3b8389f24818a3879bb5'
));
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl();
if (empty($user)) {
echo("<script> top.location.href='" . $loginUrl . "'</script>");
exit();
}
?>
<!doctype html>
<html>
<head>
<title>FB</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '220998421586280',
status: true,
cookie: true,
oauth: true
});
};
$(document).ready(function(){ //alert(1);
$('a').click(sendRequest);
});
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'I want to give you this flower!',
title: 'Give a flower to some of your friends',
data: '{"item_id":1254,"item_type":"plant"}'
},
function (response) {
//alert(JSON.stringify(response));
if (response && response.request && response.to) {
var request_ids = [];
for(i=0; i<response.to.length; i++) {
var temp = response.request + '_' + response.to[i];
request_ids.push(temp);
}
var requests = request_ids.join(',');
$.post('handle_requests.php',{uid: <?php echo $user; ?>, request_ids: requests},function(resp) {
// callback after storing the requests
});
} else {
alert('canceled');
}
});
return false;
}
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<a href="javascript:void(0);">Send</a>
</body>
</html>
Getting error like
Game Requests are only available to games.
Facebook平臺政策不允許 – WizKid
那該怎麼辦呢? – DeepikaG
然後你不這樣做。或者你這樣做,你的應用程序將被刪除 – WizKid