How do I embed a Facebook post in a DU post?
I have Windows 7 OS. The Facebook embed function is new. I tried and all I got was a post with a very long url code.
Is DU set up to allow Facebook post embedding?
Thanks for any help or advice.
I want to embed posts from my local Bernie Sanders group in my posts in the DU Bernie Sanders group.
Make7
(8,543 posts)If the text doesn't all show up right, take a screen cap of it and post the image.
DU isn't set up for this, but it looks like the facebook javascript code on opening post pages for the facebook like thingy is close enough to what is needed for embedding posts.
____________________________
test:
[div class="fb-post" data-href="https://www.facebook.com/FacebookDevelopers/posts/10151471074398553" data-width="500"][div class="fb-xfbml-parse-ignore"][blockquote cite="https://www.facebook.com/FacebookDevelopers/posts/10151471074398553" style="display:inline-block; padding:0 1em 1em 1em; border-radius:5px; border:1px solid #DDD; box-shadow:0px 1px 3px rgba(0,0,0,0.15);"][p]Be the first to know when we release a new video by subscribing to our official Facebook Developers YouTube channel! http://www.youtube.com/facebookdevelopers
EDIT: I guess it does work (with a little effort). Quick instructions: replace < and > with [ and ]. Replace the anchor tags with [link:] tags. Maybe add some style to the blockquote element for DUers that have the social media stuff disabled.
CottonBear
(21,596 posts)<div id="fb-root"></div><script> function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3"; fjs.parentNode.insertBefore(js, fjs); document, 'script', 'facebook-jssdk'));</script><div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"><p>The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.</p>Posted by <a href="https://www.facebook.com/Athens4Bernie2016">Athens for Bernie Sanders</a> on <a href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123">Sunday, July 19, 2015</a></blockquote></div></div>
OK. I need some more help. I don't see any < and > and I do not know what anchor tags are. I know nothing about html and web design. However, I am a willing student!
Make7
(8,543 posts)... but don't have time for any in depth explanation right now. I should be able to answer in more detail late tonight.
We're starting with this:
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"]<div id="fb-root"></div><script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s); if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3"; fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script><div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"><p>The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.</p>Posted by <a href="https://www.facebook.com/Athens4Bernie2016">Athens for Bernie Sanders</a> on <a href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123">Sunday, July 19, 2015</a></blockquote></div></div>
First we can throw away everything up to and including the </script> tag (DU already has this in their html):
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"]<div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"><p>The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.</p>Posted by <a href="https://www.facebook.com/Athens4Bernie2016">Athens for Bernie Sanders</a> on <a href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123">Sunday, July 19, 2015</a></blockquote></div></div>
Next, replace all < characters with [ characters (using a text editor for search and replace speeds this up):
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"][div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500">[div class="fb-xfbml-parse-ignore">[blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123">[p>The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.[/p>Posted by [a href="https://www.facebook.com/Athens4Bernie2016">Athens for Bernie Sanders[/a> on [a href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123">Sunday, July 19, 2015[/a>[/blockquote>[/div>[/div>
Then replace all > characters with ] characters:
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"][div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"][div class="fb-xfbml-parse-ignore"][blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"][p]The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.[/p]Posted by [a href="https://www.facebook.com/Athens4Bernie2016"]Athens for Bernie Sanders[/a] on [a href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"]Sunday, July 19, 2015[/a][/blockquote][/div][/div]
Now we have to change the [a href="webaddress"]text[/a] tags to the [link:webaddress|text] tags used on DU:
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"][div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"][div class="fb-xfbml-parse-ignore"][blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"][p]The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.[/p]Posted by [link:https://www.facebook.com/Athens4Bernie2016|Athens for Bernie Sanders] on [link:https://www.facebook.com/Athens4Bernie2016/posts/518526904962123|Sunday, July 19, 2015][/blockquote][/div][/div]
Then if you like, add some style to the blockquote for DUers with social media widgets turned off:
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"][div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"][div class="fb-xfbml-parse-ignore"][blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" style="display:inline-block; padding:0 1em 1em 1em; border-radius:5px; border:1px solid #DDD; box-shadow:0px 1px 3px rgba(0,0,0,0.15);"][p]The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.[/p]Posted by [link:https://www.facebook.com/Athens4Bernie2016|Athens for Bernie Sanders] on [link:https://www.facebook.com/Athens4Bernie2016/posts/518526904962123|Sunday, July 19, 2015][/blockquote][/div][/div]
And posting that should give us this (if I haven't made any mistakes):
[div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"][div class="fb-xfbml-parse-ignore"][blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" style="display:inline-block; padding:0 1em 1em 1em; border-radius:5px; border:1px solid #DDD; box-shadow:0px 1px 3px rgba(0,0,0,0.15);"][p]The "New Fowlerville ALLSTARS" enjoying some post game euphoria. Thank you Misha and Kevin Turner Photography for archiving the event. The response was so positive, and so appreciated.
CottonBear
(21,596 posts)I see that the first link takes one to the main Athens for Bernie Sanders FB page and the date link takes one to the actual FB post with a picture and all of the FB like, share and comment buttons.
I am very grateful for your expert assistance.
Perhaps this thread will be of help to other DUers. I wonder if the administrators could make programming changes that would make it easy to embed FB posts just like we can embed YouTube videos.
edit: I will try to embed another FB post when I get home from work
Make7
(8,543 posts)I made a quick html page with javascript to do the conversion - just paste in the code from Facebook in the top text area and hit the convert button, then copy the result from the bottom text area into your post on DU.
Open up Notepad.exe and paste in the text from the excerpt below, then when you save the file choose All Files (*.*) in the Save as type dropdown and call it something like FacebookCodeConvert.html (you can name it whatever you like, just make sure it ends with .html). When you double-click the saved file icon, it should open up in your default browser (or right-click and select a different browser). Depending on the browser you use, you might have to agree to allow javascript from a local file - or perhaps even change security options.
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"]<html>
<head>
<meta charset="UTF-8">
<title>DU3 code generator for FaceBook post embedding</title>
<script>
function fnConvert () {
fb0 = document.getElementById("fb_code" .value;
fb1 = fb0.split("\x3C/script\x3E" ;
fb2 = fb1[(fb1.length - 1)];
fb3 = fb2.replace(/</g, "[" ;
fb4 = fb3.replace(/>/g, "]" ;
fb5 = fb4.replace(/\x5B\x2Fa\x5D/g, "]" ;
fb6 = fb5.split("[a href=\x22" ;
fb7 = fb6[0];
for (i=1; i<fb6.length; i++) {
fb6[i] = "[link:" + fb6[i];
tmp = fb6[i].replace("\x22]", "|" ;
fb7 = fb7 + tmp;
}
fb8 = fb7.split("[blockquote " ;
fb9 = fb8[0] + "[blockquote " + fb8[1].replace("\x5D", " style=\x22display:inline-block; padding:0 1em 1em 1em; border-radius:5px; border:1px solid #DDD; box-shadow:0px 1px 3px rgba(0,0,0,0.15);\x22\x5D" ;
document.getElementById("du_code" .value = fb9;
}
</script>
</head>
<body style="background-color:#99CCFF;">
<br>
Enter embed code from FaceBook:
<br>
<textarea id="fb_code" rows="12" cols="120"></textarea>
<br>
<button type="button" onclick="fnConvert()">Convert</button>
<br>
<br>
Converted code to use on DU:
<br>
<textarea readonly id="du_code" rows="12" cols="120"></textarea>
<br>
<button type="button" onclick="document.getElementById('du_code').value='';">Clear</button>
</body>
<html>
There are probably a few more things to consider (e.g. does the embedding work for mobile users and what could/should be done if it doesn't), but I also have actual job related things to do.
Let me know if you have any issues with getting the conversion.html file to work. (Hopefully I caught and fixed any code characters/words DU might filter out of posts.)
-[font style=font-variant:small-caps;"]Make7[/font]
CottonBear
(21,596 posts)Thanks for sharing your computer programming knowledge with me and our fellow DUers.
Make7
(8,543 posts)From the Facebook embed code:
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"]<div class="fb-video" data-href="https://www.facebook.com/facebook/videos/10153231379946729/" data-width="500"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/facebook/videos/10153231379946729/"><a href="https://www.facebook.com/facebook/videos/10153231379946729/">How to Share With Just Friends</a><p>How to share with just friends.</p>Posted by <a href="https://www.facebook.com/facebook">Facebook</a> on Friday, December 5, 2014</blockquote></div></div>
We convert for use on DU:
[div class="excerpt" style="margin-left:1em; border:1px solid #bfbfbf; border-radius:0.4615em; box-shadow:-1px -1px 3px #bfbfbf inset;"][div class="fb-video" data-href="https://www.facebook.com/facebook/videos/10153231379946729/" data-width="500"][div class="fb-xfbml-parse-ignore"][blockquote cite="https://www.facebook.com/facebook/videos/10153231379946729/" style="display:inline-block; padding:0 1em 1em 1em; border-radius:5px; border:1px solid #DDD; box-shadow:0px 1px 3px rgba(0,0,0,0.15);"][link:https://www.facebook.com/facebook/videos/10153231379946729/|How to Share With Just Friends][p]How to share with just friends.[/p]Posted by [link:https://www.facebook.com/facebook|Facebook] on Friday, December 5, 2014[/blockquote][/div][/div]
And get this result:
[div class="fb-video" data-href="https://www.facebook.com/facebook/videos/10153231379946729/" data-width="500"][div class="fb-xfbml-parse-ignore"][blockquote cite="https://www.facebook.com/facebook/videos/10153231379946729/" style="display:inline-block; padding:0 1em 1em 1em; border-radius:5px; border:1px solid #DDD; box-shadow:0px 1px 3px rgba(0,0,0,0.15);"]How to Share With Just Friends[p]How to share with just friends.