Return to Snippet

Revision: 31542
at January 5, 2012 01:01 by coprolit


Updated Code
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
    </head>
<body>

<div id="fb-root"></div>

<script>
	window.fbAsyncInit = function() {
		FB.init({
			appId: "***********",
			channelURL : '//http://www.dr.dk/', // Channel File
			status: true, 
			cookie: true, 
			oauth : true, // enable OAuth 2.0
			xfbml: true
		});
	};    

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

	function streampublish(obj) {
		// params: title, targethref, imgsrc, caption, description, message
		
                // set default or passed parameters
		obj.title = (obj.title === undefined) ? "" : obj.title;
		obj.targethref = (obj.targethref === undefined) ? "" : obj.targethref;
		obj.imgsrc = (obj.imgsrc === undefined) ? "" : obj.imgsrc;
		obj.caption = (obj.caption === undefined) ? "" : obj.caption;
		obj.description = (obj.description === undefined) ? "" : obj.description;
		obj.message = (obj.message === undefined) ? "" : obj.message;
		
		FB.ui(
			{
				method: 'feed',
				name: obj.title,
				link: obj.targethref,
				picture: obj.imgsrc,
				caption: obj.caption,
				description: obj.description,
				message: obj.message
			}/*,
			function(response) {
				if (response && response.post_id) {
					alert('Post was published.');
				} else {
					alert('Post was not published.');
				}
			}*/
		);
	}
	
</script>
</body>
</html>

Revision: 31541
at September 8, 2010 23:07 by coprolit


Initial Code
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
    </head>
<body>

<div id="fb-root"></div>

<script>
	window.fbAsyncInit = function() {
		FB.init({appId: '###########', status: true, cookie: true, xfbml: true});
	};
	
	(function() {
		var e = document.createElement('script'); e.async = true;
		e.src = document.location.protocol +
		  '//connect.facebook.net/da_DK/all.js';
		document.getElementById('fb-root').appendChild(e);
	}());
	
	function streampublish()
	{
		FB.ui(
		   {
			 method: 'stream.publish',
			 message: 'har lavet en sang. Hør den på dr.dk/sangskriver',
			 attachment: {
			   name: 'Hør min sang',
			   caption: 'DR Sangskriver - Hvorfor være stille, når man kan skrive en sang...',
			   description: (
				 'DR giver dig i samarbejde med musikgymnasier og Rytmekonsertoriet, dette nye sangskriversite. ' +
				 'Her har du mulighed for at lære lidt om hvordan man skriver en sang, få gode råd af allerede kendte sangskrivere om sangskrivning og offentliggøre dit værk.'
			   ),
			   href: 'http://www.dr.dk/Undervisning/Sangskriver/Upload/sang?id='
			 },
			 action_links: [
			   { text: 'Hør sang', href: 'http://www.dr.dk/Undervisning/Sangskriver/Upload/sang?id=' }
			 ],
			 user_message_prompt: 'Giv dine venner et praj...'
		   },
		   function(response) {
			 if (response && response.post_id) {
			   //alert('Opslaget blev ikke offentliggjort.');
			 } else {
			   //alert('Post was not published.');
			 }
		   }
		 );
	}
	
</script>
</body>
</html>

Initial URL

                                

Initial Description
A more flexible version of the 'official' Facebook feed dialog example.

"The Feed Dialog prompts the user to publish an individual story to a profile's feed. This does not require any extended permissions."

"The following simple JavaScript example demonstrates using the FB.ui method in the JavaScript SDK to use the Feed Dialog:"

Initial Title
flexible feed dialog function for Facebook  JavaScript SDK FB.ui

Initial Tags
javascript, js, html, load, api, facebook

Initial Language
JavaScript