/ Published in: JavaScript
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:"
"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:"
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<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>