my code stock.com

Init JS

Snippet options

Download: Download snippet as tutorial-part-2.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<?php

// Place this in the body of your page
// Plaziere diesen Code im body deiner Seite ?>
<div id="fb-root"></div>

<?php
// Init the JS
// Javascript aufrufen
$session = $facebook->getSession();
?>
<script type="text/javascript">
window.fbAsyncInit = function() {
	FB.init({
		appId   : '<?= $facebook->getAppId(); ?>',
		<? if ($session && $session !== null): ?>session : <?= json_encode($session); ?>,<? /* don't refetch the session when PHP already has it*/ endif; ?>
		status  : true, // check login status
		cookie  : true, // enable cookies to allow the server to access the session
		xfbml   : true // parse XFBML
	});
};

(function() {
	var e = document.createElement('script');
	e.src = document.location.protocol + '//connect.facebook.net/<?= $locale; ?>/all.js';
	e.async = true;
	document.getElementById('fb-root').appendChild(e);
}());
</script>

<?php
// now the JS should be ready! so let's try it, we also need some permissions for example creating events for the user (list of permission is here http://developers.facebook.com/docs/reference/api/permissions/)
// Jetzt sollte Javascript verfügbar sein! Probieren wir es aus, wir benötigen ebenfalls einige Berechtigungen vom User (Liste mit allen Berechtigungn kann hier gefunden werden http://developers.facebook.com/docs/reference/api/permissions/)
?>
<br /><br /><fb:login-button perms="create_event"></fb:login-button><br /><br />

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.