1

I have a facebook app that's part of a fb page (it's a tab on the left side), there's an image on the app that says something like "like our page". Once they like the page I want to be able to change it out to something else. How do I go about doing this?

Basically my app is just an iframe that includes this facebook script:

<script src="//connect.facebook.net/en_US/all.js" type="text/javascript" type="text/javascript"></script>

The rest of the app is a form.

Reina
  • 315
  • 1
  • 6
  • 21

1 Answers1

1

You'll want to do something like this:

FB.Event.subscribe('edge.create',
    function(response) {
        $("#myimg").attr("src", "new_image.jpg");
    }
);

See here for more info: http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Alex Peattie
  • 26,633
  • 5
  • 50
  • 52
  • fantastic, does this need to go into any onload/document.ready events? – Reina Nov 16 '11 at 01:41
  • It's a callback, so it shouldn't really matter – Alex Peattie Nov 16 '11 at 02:01
  • thanks for your response, it doesn't seem to have worked for me, I want to be able to show the correct image even if the person has previously liked the page, your code triggers the "clicking like button" only is that correct? – Reina Nov 16 '11 at 04:00
  • That is correct, I guess I misunderstood what you wanted. Some potential solutions: http://stackoverflow.com/questions/5093398/check-if-user-liked-page and http://stackoverflow.com/questions/6246449/facebook-how-to-check-if-user-has-liked-page-and-show-content – Alex Peattie Nov 16 '11 at 04:04
  • Thanks for those links, they are closer to what I want especially the second one – Reina Nov 16 '11 at 04:25