|
Involver Developer Network : sml.ui.Facebook.share
This page last changed on Jan 24, 2012 by jed.wheeler@involver.com.
shareRenders a Facebook share dialog on your platform of choice. Params
Security IssuesFacebook does not currently support secure urls for images embedded within shares. Because the SML editable_image tag dynamically serves the image in http or https, depending on the user's current browsing mode, images inserted into a facebook share from an editable image directly will break in https mode. In order to prevent this, you can encode the editable as a variable and then use the replace filter to replace any calls for https: with a call for http:, as per the example below: ExamplesRender a share dialog with an image:{% capture share_image %}{% editable_image name:"your editable_image logo" src_only:true %}{% endcapture %}
<script type="text/javascript">
function share() {
sml.ui.Facebook.share({
user_message_prompt: "What is on your mind?",
attachment: {
name: 'Share Name',
caption: 'Share Caption',
href: '{{ application_url }}',
description: 'Share Description',
media: [{
type: 'image',
src: '{{share_image | replace:"https:", "http:"}}',
href: '{{ application_url }}'
}]
},
action_links: [{
text: 'Visit My Page',
href: '{{ application_url }}'
}],
success: function(post_id) {
sml.log("Success!");
},
error: function() {
sml.log("Error! ");
}
});
}
</script>
<a href="#_" onclick="share(); return false;">Share Me</a>
Render a share dialog with a YouTube video :<script type="text/javascript"> function share(options) { sml.ui.Facebook.share({ message: 'I like sharing!', user_message_prompt: "What is on your mind?", attachment: { name: 'Share Name', caption: options.caption, href: '{{ application_url }}', description: 'Share Description', media: [{ type: 'flash', swfsrc: options.swfsrc, imgsrc: options.imgsrc, href: 'http://www.facebook.com/Involver' }] }, action_links: [{ text: 'Visit My Page', href: '{{ application_url }}' }], success: function(post_id) { sml.log("Success!"); }, error: function() { sml.log("Error! "); } }); } </script> {% you_tube_feed %} {% for you_tube_item in you_tube_feed.you_tube_items limit: 1 %} <a href="#_" onclick="share({caption:'{{you_tube_item.title}}', swfsrc: '{{you_tube_item.embed_url}}', imgsrc:'{{you_tube_item.preview_image_url}}'}); return false;">Share Me</a> {% endfor %} {% endyou_tube_feed %} |
| Document generated by Confluence on Feb 12, 2013 09:09 |