Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

CottonBear

(21,596 posts)
Mon Jul 20, 2015, 05:55 PM Jul 2015

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.

7 replies = new reply since forum marked as read
Highlight: NoneDon't highlight anything 5 newestHighlight 5 most recent replies
How do I embed a Facebook post in a DU post? (Original Post) CottonBear Jul 2015 OP
It might work. Try copying the embed code in a reply in this thread. Make7 Jul 2015 #1
Thanks! I'll try to post in this reply. Here goes: CottonBear Jul 2015 #2
I can show you the steps... Make7 Jul 2015 #3
Wow! Thanks. CottonBear Jul 2015 #4
We should probably just have our computers do all that work for us. Make7 Jul 2015 #5
Thank you so much. I will give it a try later today. CottonBear Jul 2015 #6
The same procedure appears to work for embedding Facebook videos. Make7 Jul 2015 #7

Make7

(8,543 posts)
1. It might work. Try copying the embed code in a reply in this thread.
Mon Jul 20, 2015, 11:26 PM
Jul 2015

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

Posted by Facebook Developers on Wednesday, May 29, 2013

EDIT: I guess it does work (with a little effort). Quick instructions: replace < and > with &lsqb; and ]. Replace the anchor tags with &lsqb;link:] tags. Maybe add some style to the blockquote element for DUers that have the social media stuff disabled.

CottonBear

(21,596 posts)
2. Thanks! I'll try to post in this reply. Here goes:
Tue Jul 21, 2015, 03:02 AM
Jul 2015

<div id="fb-root"></div><script&gt 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)
3. I can show you the steps...
Tue Jul 21, 2015, 01:31 PM
Jul 2015

... 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 &lsqb; 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;"]&lsqb;div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500">&lsqb;div class="fb-xfbml-parse-ignore">&lsqb;blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123">&lsqb;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.&lsqb;/p>Posted by &lsqb;a href="https://www.facebook.com/Athens4Bernie2016">Athens for Bernie Sanders&lsqb;/a> on &lsqb;a href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123">Sunday, July 19, 2015&lsqb;/a>&lsqb;/blockquote>&lsqb;/div>&lsqb;/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;"]&lsqb;div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"]&lsqb;div class="fb-xfbml-parse-ignore"]&lsqb;blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"]&lsqb;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.&lsqb;/p]Posted by &lsqb;a href="https://www.facebook.com/Athens4Bernie2016"]Athens for Bernie Sanders&lsqb;/a] on &lsqb;a href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"]Sunday, July 19, 2015&lsqb;/a]&lsqb;/blockquote]&lsqb;/div]&lsqb;/div]

Now we have to change the &lsqb;a href="webaddress"]text&lsqb;/a] tags to the &lsqb;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;"]&lsqb;div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"]&lsqb;div class="fb-xfbml-parse-ignore"]&lsqb;blockquote cite="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123"]&lsqb;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.&lsqb;/p]Posted by &lsqb;link:https://www.facebook.com/Athens4Bernie2016|Athens for Bernie Sanders] on &lsqb;link:https://www.facebook.com/Athens4Bernie2016/posts/518526904962123|Sunday, July 19, 2015]&lsqb;/blockquote]&lsqb;/div]&lsqb;/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;"]&lsqb;div class="fb-post" data-href="https://www.facebook.com/Athens4Bernie2016/posts/518526904962123" data-width="500"]&lsqb;div class="fb-xfbml-parse-ignore"]&lsqb;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);"]&lsqb;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.&lsqb;/p]Posted by &lsqb;link:https://www.facebook.com/Athens4Bernie2016|Athens for Bernie Sanders] on &lsqb;link:https://www.facebook.com/Athens4Bernie2016/posts/518526904962123|Sunday, July 19, 2015]&lsqb;/blockquote]&lsqb;/div]&lsqb;/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.

Posted by Athens for Bernie Sanders on Sunday, July 19, 2015

CottonBear

(21,596 posts)
4. Wow! Thanks.
Tue Jul 21, 2015, 03:34 PM
Jul 2015

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)
5. We should probably just have our computers do all that work for us.
Fri Jul 24, 2015, 10:28 PM
Jul 2015

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&quot .value;
    fb1 = fb0.split("\x3C/script\x3E&quot ;
    fb2 = fb1&lsqb;(fb1.length - 1)&rsqb;;
    fb3 = fb2.replace(/</g, "&lsqb;&quot ;
    fb4 = fb3.replace(/>/g, "&rsqb;&quot ;
    fb5 = fb4.replace(/\x5B\x2Fa\x5D/g, "&rsqb;&quot ;
    fb6 = fb5.split("&lsqb;a href=\x22&quot ;
    fb7 = fb6&lsqb;0&rsqb;;
    for (i=1; i<fb6.length; i++) {
        fb6&lsqb;i&rsqb; = "&lsqb;link:" + fb6&lsqb;i&rsqb;;
        tmp = fb6&lsqb;i&rsqb;.replace("\x22&rsqb;", "|&quot ;
        fb7 = fb7 + tmp;
    }
    fb8 = fb7.split("&lsqb;blockquote &quot ;
    fb9 = fb8&lsqb;0&rsqb; + "&lsqb;blockquote " + fb8&lsqb;1&rsqb;.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&quot ;
    document.getElementById("du_code&quot .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)
6. Thank you so much. I will give it a try later today.
Sat Jul 25, 2015, 08:31 AM
Jul 2015

Thanks for sharing your computer programming knowledge with me and our fellow DUers.

Make7

(8,543 posts)
7. The same procedure appears to work for embedding Facebook videos.
Sat Jul 25, 2015, 09:32 PM
Jul 2015

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;"]&lsqb;div class="fb-video" data-href="https://www.facebook.com/facebook/videos/10153231379946729/" data-width="500"]&lsqb;div class="fb-xfbml-parse-ignore"]&lsqb;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);"]&lsqb;link:https://www.facebook.com/facebook/videos/10153231379946729/|How to Share With Just Friends]&lsqb;p]How to share with just friends.&lsqb;/p]Posted by &lsqb;link:https://www.facebook.com/facebook|Facebook] on Friday, December 5, 2014&lsqb;/blockquote]&lsqb;/div]&lsqb;/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.

Posted by Facebook on Friday, December 5, 2014
Latest Discussions»Help & Search»Computer Help and Support»How do I embed a Faceboo...