Webmaster Forum

Webmaster Forum (http://www.v7n.com/forums/index.php)
-   Coding Forum (http://www.v7n.com/forums/forumdisplay.php?f=16)
-   -   Facebook like button won't stay "liked" (http://www.v7n.com/forums/showthread.php?t=254611)

DSeyir 06-06-2011 01:09 AM

Facebook like button won't stay "liked"
 
Hi, i'm trying to understand something here:
I generated a facebook like+send button and placed it on the place I want to show on WP template page, but when I press the button it doesn't stay, it reverts back

code I used

Code:

<div id="fb-root"></div><script src="http://connect.facebook.net/pt_PT/all.js#appId=171704749557556&amp;xfbml=1"></script><fb:like href="" send="true" layout="button_count" width="100" show_faces="false" font=""></fb:like>
any idea why this happens

page is fotografiasdeangola.com/en/fotografias-de-lunda-sul

(sorry to post the page, is just so you can see what Im talking about)

JasonWright337 06-07-2011 12:04 AM

I think you miss your site url

<div id="fb-root"></div><script src="http://connect.facebook.net/pt_PT/all.js#appId=171704749557556&amp;xfbml=1"></script><fb:like href="http://www.yoursite.com" send="true" layout="button_count" width="100" show_faces="false" font=""></fb:like>

Change http://www.yoursite.com with your site url hope it will work

DSeyir 06-07-2011 01:05 AM

nope, if you do that you cannot use it in a dynamic page, if you leave empty it gets the page url by default

nemrod 06-07-2011 01:30 AM

I would just remove the attribute completely if I wanted it to get the current page URL. On the other hand I would probably use PHP to get the URL I wanted to be liked dynamically based on page either way instead of relying on such things.

DSeyir 06-07-2011 01:54 AM

hey nemrod, I still owe you the vodka bottle, hahaha

look, I have this on my header.php

PHP Code:

<meta property="fb:admins" content="*****************"/>
<meta property="og:type" content="article" />
<?php if(is_home()) {
?><meta property="og:title" content="Fotografias de Angola" /><?php
} else {
?><meta property="og:title" content="<?php the_title_attribute$args ); ?>" /><?php
}
?>
<?php 
if (is_home())
    echo 
'<meta property="og:url" content="http://fotografiasdeangola.com/" />';
    else echo 
'<meta property="og:url" content="'.get_permalink().'" />';
?>

<?php wp_head(); ?>

and I load the script using
Code:

<script>
  window.fbAsyncInit = function() {
    FB.init({appId: '**************', status: true, cookie: true,
            xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/pt_PT/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

but even with this the like button doesn't "stay", the only way I found to it to stay is by using

Code:

<fb:like href="<?php the_permalink() ?>" send="true" layout="button_count" width="100" show_faces="false" font=""></fb:like>
but like this the post in facebook looks like crap, I mean it parses the url with "http://..."

nemrod 06-07-2011 02:20 AM

I'm using the permalink on my blog and it shows up just fine on Facebook.

http://i.imgur.com/O3Ks3.png

That's me liking this post.

I'm using the iframe code though, more precisely this here:
HTML Code:

<iframe src="http://www.facebook.com/plugins/like.php?app_id=202937996418289&amp;href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;send=false&amp;layout=button_count&amp;width=80&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>

DSeyir 06-07-2011 04:30 AM

well, I'm trying to avoid iframes, specially because it's harder to position them where I want on the site

nemrod 06-07-2011 04:32 AM

You do realise that the code you're using is replaced with an iframe through the JS you're including, right? Take a look at the generated source code (ctrl+shift+j in Chrome). ;)

DSeyir 06-07-2011 10:12 AM

great, I didn't realized that :(

anyway, I prefer to load the script on one side and so I can use the XFBML around the website, but I guess that's the not the issue regarding if it stays "liked" or not.

DSeyir 06-07-2011 10:32 AM

OK, it's working now.
and I just realized that facebook tells you to load the script on one side so that you may use the xfbml and the open graph, and when you generate the a like button it gives the option , the iframe and the xfb.., and in the xfb.. comes the script again.

I guess I'm missing something


All times are GMT -7. The time now is 03:55 AM.

3.8.7