您必須先創建一個Facebook應用程序。
繼承人創建Facebook應用程序的鏈接。 https://www.facebook.com/developers/createapp.php
然後把下面的代碼放到你的應用程序中。
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
//Your app details here
FB.init({appId: 'your-app-id', status: true, cookie: true, xfbml: true});
};
//Load the SDK asynchronously
(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);
}());
</script>
<fb:serverfbml>
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="url-after-inviting"
method="POST"
invite="true"
type="Name of site"
content="Text you want to keep along.
<fb:req-choice url='link-to-your-website'
label='<?php echo htmlspecialchars("Invite Now!",ENT_QUOTES); ?>'/>"
>
<fb:multi-friend-selector
showborder="false"
actiontext="title-text"
exclude_ids="<?php //echo $excludeIds; ?>"
rows="3"
/>
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
想知道如何在PHP端做到這一點。有任何想法嗎? – Ashfame 2011-06-13 07:49:05
你可以在你的php文件中編寫相同的代碼,因爲我們可以放入JavaScript php文件。只是把它放在外面標籤 – programmer 2011-06-13 07:57:12
程序員:我真的必須寫facebook應用嗎?沒有創建Facebook應用程序可以使用api嗎? – 2011-06-13 09:01:34