1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Creating a dynamic Facebook share button

Discussion in 'Facebook API' started by gavin watson, Mar 3, 2014.

  1. #1
    I am stuck with this one...

    I have a website that plays music. The page updates automatically to display the current song being played and the image of the artist. The website also allows visitors to request songs. What I want to do is allow users to then share their request on Facebook, so I have added the code below.

    Initially, when you pressed the Facebook button, it would pop up iwth a box which contained all the correct info (song, artist, image, etc), but would not post correctly to Facebook (the dynamic info such as title and image would be missing). Now, recently, it doesn't even populate the pop up correctly.

    I'm stuck and cannot figure out how to get this to work correctly, can anyone help me?

    Thanks.

    <a class="facebook" target="_blank" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=300')" href="http://www.facebook.com/sharer.php?s=100&p[title]=I'm listening to <?php echo $currentSong->title . ' by ' . $currentSong->artist; ?>&p[summary]=Join me and listen right now or request your own song&p=mydomain,com&p[images[0]=<?php echo $largeimg; ?>"><img src="mydomain,com/new/images/facebook.png" width="32" height="32" border="0" style="padding-top:5px; padding-right:4px "></a>
    Code (markup):

     
    gavin watson, Mar 3, 2014 IP
  2. gavin watson

    gavin watson Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    I've put commas in the domain name instead of dots to be able to post it.
     
    gavin watson, Mar 3, 2014 IP
  3. Daniel15

    Daniel15 Member

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    Can you provide an example /sharer.php URL?
    How are you re-generating the URL when the song changes? Are you doing an AJAX request?

    I'd suggest building the URL directly in JavaScript.
     
    Daniel15, Mar 9, 2014 IP