![](/img/trans.png)
[英]Google Script App: Why can't I send ajax requests to my web app?
[英]Why doesn't my Facebook app send Invite requests?
我已經為此工作了幾天,但找不到丟失的內容。 有人有建議嗎?
似乎缺少了一些東西,但我不知道會是什么。
我沒有收到任何錯誤。 共享按鈕可以工作(共享到自己的牆上),但是邀請似乎根本沒有做任何事情。
我已經用X替換了我的appid。
<html>
<head>
<title>App Name</title>
</head>
<body>
<div id="fb-root"></div>
<script>
var publish = {
method: 'stream.publish',
display: 'popup', // force popup mode
attachment: {
name: 'Connect',
caption: 'The Facebook Connect JavaScript SDK',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
href: 'http://app-address.com/'
}
};
function publish1() {
FB.ui(publish);//, Log.info.bind('stream.publish callback'));
}
</script>
<button class="btn" id="send-to-many">Send to Many</button>
<button onclick="publish1()">Click</button>
</body>
<script>
window.fbAsyncInit = function() {
console.log('Initing facebook...');
FB.init({
appId: 'xxxxxxxxxxxxxxx',
status: true,
frictionlessRequests: true,
cookie: true,
xfbml: true
});
console.log('... done');
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
document.getElementById('send-to-many').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'This is a test of the App-Name invite.'
}, requestCallback);
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='home';
} else {
// No requests sent, you can do what you want (like...nothing, and stay on the page).
}
}
}
</script>
</html>
您的代碼看起來不錯。 您的Facebook應用設置中必須存在錯誤。 對於邀請功能,您必須在您的Facebook應用程序設置中提供“畫布URL”和“安全畫布URL”。 您也可以在下面嘗試我的代碼。 這是一個非常簡單的代碼。
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'APP_ID',
cookie:true,
status:true,
xfbml:true
});
function FacebookInviteFriends()
{
FB.ui({
method: 'apprequests',
message: 'Your Message diaolog'
});
}
</script>
//HTML Code
<div id="fb-root"></div>
<a href='#' onclick="FacebookInviteFriends();">
Facebook Invite Friends Link
</a>
在這里,您必須再編寫一個JavaScript代碼來破壞iframe。 這樣鏈接就不會在facebook內部打開。 您還必須在您的首頁或網站的其他頁面上編寫相同的js代碼,以使應用程序重定向。
<script type='text/javascript'>
if (top.location!= self.location)
{
top.location = self.location
}
</script>
如有任何其他疑問,請隨時在此處寫。
我遇到了類似的問題,發現您必須單擊“ DONE
按鈕。 這是一個表單,“ DONE
按鈕提交表單。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.