Monday, 15 August 2011

php - Dynamic Facebook Like button -



php - Dynamic Facebook Like button -

i have various pages so:

www.mysite/directory/title?title=$title

so can see each page dynamic. has been asked many times before want have facebook buttons generated dynamic url. have notied there changes button @ end of lastly year , have been trying find recent posts this.

the problem have either facebook error states requires absolute url or refers button setup facebook, in case login page.

i have tried following:

// load sdk's source asynchronously // note debug version beingness actively developed , might // contain type checks overly strict. // please study such bugs using bugs tool. (function(d, debug){ var js, id = 'facebook-jssdk', ref = d.getelementsbytagname('script')[0]; if (d.getelementbyid(id)) {return;} js = d.createelement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_us/all" + (debug ? "/debug" : "") + ".js"; ref.parentnode.insertbefore(js, ref); }(document, /*debug*/ false)); </script> <script type="text/javascript"> var surl = "http://www.mysite.com/"; document.getelementbyid('fb').setattribute('href', surl); </script> <div class="fb-like" id="fb" data-send="true" data-layout="button_count" data-width="60" data-show-faces="true"></div>

and:

<?php $url = basename($_server['request_uri']);?> <div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div>

along with:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_us/all.js#appid=186609524720286&amp;xfbml=1"></script> <div id="fblikeblock"></div> <script> var url = 'http://apps.facebook.com/inflatableicons/image_preview.html?y=120'; jquery("#fblikeblock").html('<fb:like id="fblike" href="'+url+'" send="true" width="450" show_faces="true" font=""></fb:like>'); fb.xfbml.parse(document.getelementbyid('fblikeblock')); console.log(document.getelementbyid('fblikeblock')); </script>

and not forgetting:

<fb:like></fb:like>

after invoking fb.xfbml.parse.

i having no success, can see have tried many methods , quite stuck. ideas?

thanks!

edited:

the url encoded, today tried next - still same result. everywhere have looked on stack states of these ways should working, getting nowhere:

<div class="fb-like" id="fb" data-href="<?php urlencode($url);?>" data-send="true" data-width="450" data-show-faces="true"></div>

any ideas?

use data-href url. https://developers.facebook.com/docs/reference/plugins/like/

php javascript facebook facebook-like

No comments:

Post a Comment