CodeIgniter Forums
Custom post on facebook - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Custom post on facebook (/showthread.php?tid=64358)



Custom post on facebook - Bhavesh - 02-12-2016

Hi Friends,

I have used java script for custom share post on Facebook.

Below is my code

PHP Code:
<script>
var 
FB;
window.fbAsyncInit = function() {
FB.init({
appId 'xxxxxxx',
xfbml true,
version 'v2.4'
});
};
(function(
dsid){
var 
jsfjs 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";
fjs.parentNode.insertBefore(jsfjs);
}(
document'script''facebook-jssdk'));
function 
ShareOnFB()
{
FB.ui({
method'share',
href'http://www.[MYSITE].com',
caption'QeRetail - www.[MYSITE].com',
description'Wow...!!! I have got Free test',
title'We maintain & Market your online store',
picture'[SITE_URL]/images/banner.jpg',
}, function(
response){});
}
</
script>
<
a href="#" onclick="ShareOnFB();">Share on FB</a>
</
body>
</
html



I want to add multiple links in banner, caption etc .
Is it possible?
Please give me suggestion.
Thanks in advance


RE: Custom post on facebook - mwhitney - 02-15-2016

Since you're just using an onclick attribute in your link to call a JavaScript function, you can do this in as many places as you'd like. In most cases, I would add a class or some set ID values to the links, then update the links or add an event handler to the page's body element to set the function as the event handler for those links. This is basic JavaScript and not really related to CodeIgniter.